Caterina
Caterina

Reputation: 987

Linking with 2 libraries

I'm trying to link a program with 2 libraries this way:

LNOPT = -Wl,-rpath,$(MKLROOT)/lib/intel64  -Wl,-rpath,/opt/intel/compilers_and_libraries_2019.0.117/linux/compiler/lib/intel64_lin

However I either get one of these errors:

./dftb+: error while loading shared libraries: libmkl_gf_lp64.so: cannot open shared object file: No such file or directory

./dftb+: error while loading shared libraries: libiomp5.so: cannot open shared object file: No such file or directory

Depending on which -rpath I put first. How can I address this problem?

Upvotes: 0

Views: 503

Answers (1)

v-joe
v-joe

Reputation: 366

Is putting both paths (separated by :) in the environment variable LD_LIBRARY_PATH at runtime an option? (This way, the hard-coded rpath doesn't have to work.) Example:

LD_LIBRARY_PATH=$(MKLROOT)/lib/intel64:/opt/intel/compilers_and_libraries_2019.0.117/linux/compiler/lib/intel64_lin ./dftb+

Or put export LD_LIBRARY_PATH=$(MKLROOT)/lib/intel64:/opt/intel/compilers_and_libraries_2019.0.117/linux/compiler/lib/intel64_lin in some profile rc file so that the library path is always set.

In either case, if there are already other paths which are needed in LD_LIBRARY_PATH add the above to it via LD_LIBRARY_PATH=$(MKLROOT)/lib/intel64:/opt/intel/compilers_and_libraries_2019.0.117/linux/compiler/lib/intel64_lin:$LD_LIBRARY_PATH instead of simply overriding LD_LIBRARY_PATH completely.

What could/should also work is sourceing the environment variable setup .sh files shipped with both the Intel compilers and the MKL, which, among other variables such as MKLROOT, should setup LD_LIBRARY_PATH pointing to both libiomp5.so and also the dynamic MKL link libraries.

Upvotes: 2

Related Questions