首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >显式链接intel icpc openmp

显式链接intel icpc openmp
EN

Stack Overflow用户
提问于 2017-08-27 21:49:14
回答 2查看 1.3K关注 0票数 3

我在下面的$HOME/tpl/intel上安装了英特尔编译器。当我在启用hello_omp.cpp的情况下编译一个简单的openMP

代码语言:javascript
复制
#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编译器和相应的库。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-08-28 06:12:38

对于您的问题,您有两个简单的解决方案:

  1. 静态地链接到Intel运行时库: ~/tpl/intel/bin/icpc -O3 -qopenmp -static_intel hello_omp.cpp
代码语言:javascript
复制
- 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.

  1. 使用链接器选项-rpath~/tpl/intel/bin/icpc -O3 -qopenmp -Wl,-rpath=$HOME/tpl/intel/lib/intel64 hello_omp.cpp将动态库的搜索路径添加到二进制文件中 注意使用-Wl,将选项传输到链接器。 我想这更像是你所追求的,而不是我提出的第一个解决方案,所以我让你设计出相对于你的利与弊。
票数 2
EN

Stack Overflow用户

发布于 2017-09-06 18:46:45

Intel将compilervars.sh脚本放在bin目录中,该脚本将在源目录中设置适当的env变量(如LD_LIBRARY_PATH、LIBRARY_PATH和PATH ),并具有托管OpenMP运行时库和其他编译器特定库(如libsvml (短向量数学库)或libimf (更优化版本的libm) )的正确目录。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45909648

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档