Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

File not find during link

Hang_S_
Beginner
539 Views

I'm working in a Linux system ( Ubuntu 12.04 ), using ifort linking the main program main.f90 and library lib.a. If I use command

ifort main.f90 /home/tom/lib/lib.a

then everything is fine. But if I use

ifort -L/home/tom/lib main.f90 lib.a

then ifort gives an error

ifort: error #10236: File not found:  'lib.a'

 

Why the -L specification doesn't work? When I want to use the environment variable LIBRARY_PATH ? It still gives me that error, why that happen? Must I specify the full path every time I link the library?

0 Kudos
1 Solution
Kevin_D_Intel
Employee
539 Views

Libraries on Linux are found using -L (and/or LIBRARY_PATH) along with the lower-case "l" (i.e. -l<name> ) option. When using -l you leave off the leading "lib" portion of the library name as the linker automatically prepends "lib" to the name when searching for it, so if your library is named libEXP.a, then you link using something like:

ifort -L/home/tom/lib -lEXP main.f90

You will need add some additional characters to your library name and not try using a library named lib.a.

Hope that make sense.

View solution in original post

0 Kudos
3 Replies
Kevin_D_Intel
Employee
540 Views

Libraries on Linux are found using -L (and/or LIBRARY_PATH) along with the lower-case "l" (i.e. -l<name> ) option. When using -l you leave off the leading "lib" portion of the library name as the linker automatically prepends "lib" to the name when searching for it, so if your library is named libEXP.a, then you link using something like:

ifort -L/home/tom/lib -lEXP main.f90

You will need add some additional characters to your library name and not try using a library named lib.a.

Hope that make sense.

0 Kudos
Hang_S_
Beginner
539 Views

Kevin Davis (Intel) wrote:

Libraries on Linux are found using -L (and/or LIBRARY_PATH) along with the lower-case "l" (i.e. -l<name> ) option. When using -l you leave off the leading "lib" portion of the library name as the linker automatically prepends "lib" to the name when searching for it, so if your library is named libEXP.a, then you link using something like:

ifort -L/home/tom/lib -lEXP main.f90

You will need add some additional characters to your library name and not try using a library named lib.a.

Hope that make sense.

 

Thank you very much! It works!

0 Kudos
Kevin_D_Intel
Employee
539 Views

Great. Glad that helped.

0 Kudos
Reply