"library not found" message for a library that exists

"library not found" message for a library that exists

Keep getting a "library not found" error when the library does, in fact, exist:

deborah> set BLAS95=$MKLPATH/libmkl_blas95_lp64.a
deborah> ls -al $BLAS95
-rw-r--r--  1 root  600  429896 Jul 26  2012 /opt/intel/Compiler/11.1/067/Frameworks/mkl/lib/em64t/libmkl_blas95_lp64.a
deborah> ifort -l$BLAS95 hello.f90
ld: library not found for -l/opt/intel/Compiler/11.1/067/Frameworks/mkl/lib/em64t/libmkl_blas95_lp64.a

Using Mac OS X 10.7.5


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

If you specify the full path for a library, leave out the leading "-l" in the command that you use to do the linking.

The -l option tells the linker to decorate the given name, so in your case the linker is looking, in the default library paths, for a library named "lib/opt/intel/Compiler/11.1/067/Frameworks/mkl/lib/em64t/libmkl_blas95_lp64.a.a" ---i.e., the prefix "lib" and the suffix ".a" are added by the linker.

What you probably want is:

ifort -L$MKLPATH -lmkl_blas95_lp64 hello.f90

That is, the -L option tells the linker where to look for the library.  If you don't want decoration, remove -l and provide the full library name, including extension.  If you have more than one library, you'll probably need to surround them with -Wl,--start-group and -Wl,--end-group, since by default the linker checks archives only once and in the given order.




Leave a Comment

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