静态链接OpenMP

发布于 2025-01-21 16:46:23 字数 926 浏览 2 评论 0原文

我有一个带有OpenMP功能的CPP文件,我想静态地链接它。我已经尝试了建议的解决方案在这里但没有成功。

如果我使用以下命令:

g++ -c main.cpp -fopenmp -o main.o
g++ -static -lgomp -lpthread main.o -o main

我会发现错误,说没有提及“ dlopen,dlsym,dlclose,dlerror”。

因此,我还尝试在链接命令中添加-fopenmp标志:

g++ -c main.cpp -fopenmp -o main.o
g++ -static -lgomp -lpthread -fopenmp main.o -o main

现在我没有收到链接错误,但是我收到了此警告:

/usr/lib/gcc/x86_64-linux-gnu/7/libgomp.a(target.o): in function "gomp_target_init":
(.text+0x8b): attention: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

此警告建​​议我 static linking 还没有成功(即使ldd main状态不是动态的可执行文件

有什么建议吗?

I have a cpp file with openMP functions and I want to link it statically. I have already tried solution proposed here but without success.

If I use the following commands:

g++ -c main.cpp -fopenmp -o main.o
g++ -static -lgomp -lpthread main.o -o main

I get errors saying that there is no reference to "dlopen, dlsym, dlclose, dlerror".

So, I tried also to add -fopenmp flag in linking command:

g++ -c main.cpp -fopenmp -o main.o
g++ -static -lgomp -lpthread -fopenmp main.o -o main

Now I don't receive linking errors, but I get this warning:

/usr/lib/gcc/x86_64-linux-gnu/7/libgomp.a(target.o): in function "gomp_target_init":
(.text+0x8b): attention: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

This warning suggest me that static linking has not been successful (even if ldd main states is not a dynamic executable.

Any suggestion?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文