我在下面的$HOME/tpl/intel上安装了英特尔编译器。当我在启用hello_omp.cpp的情况下编译一个简单的openMP
#include <omp.h>
#include <iostream>
int main ()
{
#pragma omp parallel
{
std::cout << "Hello World" << std::endl;
}
return 0;
}我使用~/tpl/intel/bin/icpc -O3 -qopenmp hello_omp.cpp进行编译,但是当我运行时会得到以下错误:./a.out: error while loading shared libraries: libiomp5.so: cannot open shared object file: No such file or directory。
我想在不使用LD_LIBRARY_PATH的情况下显式地链接intel编译器和相应的库。
发布于 2017-08-28 06:12:38
对于您的问题,您有两个简单的解决方案:
~/tpl/intel/bin/icpc -O3 -qopenmp -static_intel hello_omp.cpp- Pros: you don't have to care where the Intel run time environment is installed on the machine where you run the binary, or even having it installed altogether;
- Cons: your binary becomes bigger and won't allow to select a different (more recent ideally) run time environment even when it is available.
-rpath~/tpl/intel/bin/icpc -O3 -qopenmp -Wl,-rpath=$HOME/tpl/intel/lib/intel64 hello_omp.cpp将动态库的搜索路径添加到二进制文件中
注意使用-Wl,将选项传输到链接器。
我想这更像是你所追求的,而不是我提出的第一个解决方案,所以我让你设计出相对于你的利与弊。发布于 2017-09-06 18:46:45
Intel将compilervars.sh脚本放在bin目录中,该脚本将在源目录中设置适当的env变量(如LD_LIBRARY_PATH、LIBRARY_PATH和PATH ),并具有托管OpenMP运行时库和其他编译器特定库(如libsvml (短向量数学库)或libimf (更优化版本的libm) )的正确目录。
https://stackoverflow.com/questions/45909648
复制相似问题