如何更改路径以修复错误"./main:加载共享库 libmkl_core.so 时出错?
How to change path to fix error "./main: error while loading shared library libmkl_core.so?
我已经安装了英特尔 mkl 库。 内容有路径/home/user/intel/..... .我必须使用提到它的 make 文件运行一个C++代码。
CC = /home/user/intel/bin/icpc -g
INCLUDE = -I/home/user/intel/mkl/include
LIB = -L/home/user/intel/mkl/lib/intel64 -lmkl_core -lmkl_intel_lp64 -lmkl_intel_thread -liomp5 -lpthread -std=c++11
我已经成功安装了parallel_studio_xe_2019_update5_cluster_edition . 但是在加载共享库时仍然收到一条错误消息 ./main :error。如何修复此错误。我需要做哪些更改?
与共享库的链接实际上分两步完成:构建时(链接器需要查找库(;而运行时(当操作系统动态加载时需要查找库(。
使用安装在非标准位置的库进行生成时,可以使用-L
选项告诉链接器在何处查找库。不幸的是,它没有告诉动态加载程序库的位置。
要告诉动态加载程序动态库的位置,有几种方法,我建议在构建时添加一个标志,以便链接器将位置嵌入到可执行程序文件中以供动态加载程序查看。这是通过选项-Wl,-rpath,/path/to/lib/directory
完成的。
在您的情况下,您需要将选项-Wl,-rpath,/home/user/intel/mkl/lib/intel64
添加到LIB
makefile 变量中。
为了澄清,整行应该是
LIB = -L/home/user/intel/mkl/lib/intel64 -Wl,-rpath,/home/user/intel/mkl/lib/intel64 -lmkl_core -lmkl_intel_lp64 -lmkl_intel_thread -liomp5 -lpthread -std=c++11
也就是说,您既需要旧的-L
选项(就像您当前在显示的代码中一样(并添加新选项。
相关文章:
- 将成员变量添加到共享库中的类中,不会破坏二进制兼容性吗
- 是否可以通过C++扩展强制多个python进程共享同一内存
- 在cuda线程之间共享大量常量数据
- 如何从具有移动语义的类对象中生成共享指针
- 在c代码之间共享数据的最佳方式
- 在两个类中共享相同的函数调用,并在不需要时避免空实例化
- 将静态库链接到不带-fPIC的共享库中
- 为什么std::互斥需要很长的、非常不规则的时间来共享
- 使用Boost Interprocess创建托管共享内存需要很长时间
- 无法在Ubuntu上将共享库与Eclipse链接
- 从python调用openMP共享库时,未定义opnMP函数
- 在为LINUX创建共享库时,如何避免STL的私有/弱副本
- 为什么我的共享库中存在展开符号
- 使用共享指针的函数调用,其对象应为 const
- 具有两个独占锁组的共享锁
- 共享队列的线程安全
- 共享指针和具有自定义删除程序的唯一指针之间的语法差异背后的任何原因
- 多个"常量引用"变量可以共享同一个内存吗?
- 如何访问由共享指针保存的类方法?
- 从矢量或地图中删除共享指针