我尝试这样链接一个程序和两个库:
LNOPT = -Wl,-rpath,$(MKLROOT)/lib/intel64 -Wl,-rpath,/opt/intel/compilers_and_libraries_2019.0.117/linux/compiler/lib/intel64_lin然而,我要么得到这些错误中的一个:
./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这取决于我放在第一位的-rpath。我如何解决这个问题?
发布于 2018-12-18 06:30:41
在运行时将两个路径(由:分隔)放入环境变量LD_LIBRARY_PATH中是一种选择吗?(这样,硬编码的rpath就不必工作了。)示例:
LD_LIBRARY_PATH=$(MKLROOT)/lib/intel64:/opt/intel/compilers_and_libraries_2019.0.117/linux/compiler/lib/intel64_lin ./dftb+或者将export LD_LIBRARY_PATH=$(MKLROOT)/lib/intel64:/opt/intel/compilers_and_libraries_2019.0.117/linux/compiler/lib/intel64_lin放在某个配置文件rc文件中,以便始终设置库路径。
在任何一种情况下,如果LD_LIBRARY_PATH中已经有需要的其他路径,请通过LD_LIBRARY_PATH=$(MKLROOT)/lib/intel64:/opt/intel/compilers_and_libraries_2019.0.117/linux/compiler/lib/intel64_lin:$LD_LIBRARY_PATH将上面的路径添加到其中,而不是简单地完全覆盖LD_LIBRARY_PATH。
可以也应该起作用的是设置英特尔编译器与MKL附带的环境变量source .sh文件,该文件应设置指向libiomp5.so和动态MKL链接库的LD_LIBRARY_PATH。
https://stackoverflow.com/questions/53800519
复制相似问题