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

Ifort disrespecting -L flag

Kacper_Kowalik
Beginner
670 Views
Hi,
I have following problem. Currently ifort seems to prefer linking libs found in /usr/lib no matter how hard I try to convince it to do otherwise. Quick example:

$ ifort -dryrun hdf5_test.f90 -I${EPREFIX}/usr/include -Xlinker -L${EPREFIX}/usr/lib -lhdf5_fortran -lhdf5

gets you ld called with:

ld \\
/usr/lib/../lib64/crt1.o \\
/usr/lib/../lib64/crti.o \\
/data/kkowalik/prefix/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.2/crtbegin.o \\
--eh-frame-hdr \\
-dynamic-linker \\
/lib64/ld-linux-x86-64.so.2 \\
-o \\
a.out \\
/opt/intel/composer_xe_2011_sp1.8.273/compiler/lib/intel64/for_main.o \\
-L/opt/intel/composer_xe_2011_sp1.8.273/compiler/lib/intel64 \\
-L/opt/intel/composer_xe_2011_sp1.8.273/tbb/lib/intel64//cc4.1.0_libc2.4_kernel2.6.16.21 \\
-L/opt/intel/composer_xe_2011_sp1.8.273/compiler/lib/intel64 \\
-L/opt/intel/composer_xe_2011_sp1.8.273/tbb/lib/intel64//cc4.1.0_libc2.4_kernel2.6.16.21 \\
-L/opt/intel/composer_xe_2011_sp1.8.273/compiler/lib/intel64 \\
-L/data/kkowalik/prefix/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.2 \\
-L/data/kkowalik/prefix/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.2/../../../../x86_64-pc-linux-gnu/lib/../lib \\
-L/data/kkowalik/prefix/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.2/../../../../lib64 \\
-L/data/kkowalik/prefix/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.2/../../../../lib \\
-L/lib/../lib64 \\
-L/usr/lib/../lib64 \\
-L/opt/intel/composer_xe_2011_sp1.8.273/compiler/lib/intel64 \\
-L/opt/intel/composer_xe_2011_sp1.8.273/tbb/lib/intel64//cc4.1.0_libc2.4_kernel2.6.16.21 \\
-L/data/kkowalik/prefix/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.2/../../../../x86_64-pc-linux-gnu/lib \\
-L/data/kkowalik/prefix/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.2/../../.. \\
-L/lib64 \\
-L/lib \\
-L/usr/lib64 \\
-L/usr/lib \\
/tmp/ifort6I7DVt.o \\
-L/data/kkowalik/prefix/usr/lib \\
-lhdf5_fortran \\
-lhdf5 \\
-Bstatic \\
-lifport \\
-lifcore \\
-limf \\
-lsvml \\
-Bdynamic \\
-lm \\
-Bstatic \\
-lipgo \\
-lirc \\
-u \\
__pthread_once \\
-Bdynamic \\
-lpthread \\
-lc \\
-lgcc \\
-lgcc_s \\
-Bstatic \\
-lirc_s \\
-Bdynamic \\
-ldl \\
-lc \\
/data/kkowalik/prefix/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.2/crtend.o \\
/usr/lib/../lib64/crtn.o

I'd like to use hdf5 lib located in /data/kkowalik/prefix/usr/lib, but strace for the beforementioned command shows the following:
...
open("/opt/intel/composer_xe_2011_sp1.8.273/compiler/lib/intel64/libhdf5_fortran.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/intel/composer_xe_2011_sp1.8.273/compiler/lib/intel64/libhdf5_fortran.a", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/intel/composer_xe_2011_sp1.8.273/tbb/lib/intel64//cc4.1.0_libc2.4_kernel2.6.16.21/libhdf5_fortran.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/intel/composer_xe_2011_sp1.8.273/tbb/lib/intel64//cc4.1.0_libc2.4_kernel2.6.16.21/libhdf5_fortran.a", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/intel/composer_xe_2011_sp1.8.273/compiler/lib/intel64/libhdf5_fortran.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/intel/composer_xe_2011_sp1.8.273/compiler/lib/intel64/libhdf5_fortran.a", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/intel/composer_xe_2011_sp1.8.273/tbb/lib/intel64//cc4.1.0_libc2.4_kernel2.6.16.21/libhdf5_fortran.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/intel/composer_xe_2011_sp1.8.273/tbb/lib/intel64//cc4.1.0_libc2.4_kernel2.6.16.21/libhdf5_fortran.a", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/intel/composer_xe_2011_sp1.8.273/compiler/lib/intel64/libhdf5_fortran.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/intel/composer_xe_2011_sp1.8.273/compiler/lib/intel64/libhdf5_fortran.a", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/data/kkowalik/prefix/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.2/libhdf5_fortran.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/data/kkowalik/prefix/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.2/libhdf5_fortran.a", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/data/kkowalik/prefix/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.2/../../../../lib64/libhdf5_fortran.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/data/kkowalik/prefix/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.2/../../../../lib64/libhdf5_fortran.a", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/../lib64/libhdf5_fortran.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/../lib64/libhdf5_fortran.a", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/../lib64/libhdf5_fortran.so", O_RDONLY) = 9

As you can see /usr/lib64/libhdf5_fortran.so gets picked up. I've tried passing plain -L, -Xlinker -L, -Wl,-L with no luck. The only workaround I've found is to provide ifort with absolute path to .so files:
$ ifort hdf5_test.f90 -I${EPREFIX}/usr/include ${EPREFIX}/usr/lib/libhdf5_fortran.so ${EPREFIX}/usr/lib/libhdf5.so
Are there any other options I'm missing?
Best regards,
Kacper Kowalik
0 Kudos
2 Replies
Kevin_D_Intel
Employee
670 Views
You can try: -nodefaultlibs

This option requires that youthen provide all the necessary paths to the system libs on your command line but you can list those after your $(EPREFIX)/usr/lib path so you link the version of the duplicate named library that you want.
0 Kudos
Kacper_Kowalik
Beginner
670 Views
Sorry for the late reply, I've somehow missed your post.

-nodefaultlibs doesn't help.

ifort -dryrun -nodefaultlibs hdf5_test.f90 -I${EPREFIX}/usr/include -Xlinker -L${EPREFIX}/usr/lib -lhdf5_fortran -lhdf5 -lc -lm -lifport -lifcore -lsvml -lintlc -ldl

fails the same way.
0 Kudos
Reply