File not find during link

File not find during link

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?

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Best Reply

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.

Quote:

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!

Great. Glad that helped.

Leave a Comment

Please sign in to add a comment. Not a member? Join today