【问题标题】:Linking with 2 libraries与 2 个库链接
【发布时间】:2018-12-16 08:13:55
【问题描述】:

我正在尝试以这种方式将程序与 2 个库链接:

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。我该如何解决这个问题?

【问题讨论】:

    标签: makefile linker fortran shared-libraries intel


    【解决方案1】:

    是否可以在运行时将两个路径(由: 分隔)放入环境变量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

    还可以/应该起作用的是 sourceing 环境变量设置 .sh 英特尔编译器和 MKL 附带的文件,除了 MKLROOT 等其他变量之外,它应该设置指向 libiomp5.so 的 LD_LIBRARY_PATH以及动态 MKL 链接库。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-09
      • 2012-08-09
      • 2018-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-02
      • 2011-04-09
      相关资源
      最近更新 更多