CUDA CUDPP .so 构建

发布于 2024-10-05 05:20:13 字数 421 浏览 0 评论 0原文

我想在我的项目中使用 CUDPP 库。我已从项目页面下载了源代码。不幸的是,当我运行“make”时,只有静态库构建。我查看了 Makefile 文件,没有找到任何动态库配置。我不想在项目中保留静态库 - 这是完全不可移植的方式。

我的问题是:如何构建 CUDPP 的 .so 动态库,而不需要编写自己的 Makefile/手动编译它?也许有人已经做到了?

编辑:我已将“g++”替换为“g++ -fPIC”,将“gcc”替换为“gcc -fPIC”,将“nvcc”替换为“nvcc -Xcompiler -fpic”。当我从存档中解压 obj 文件并将它们链接到共享库时,我没有收到任何错误。但是,当与该库链接时,我的应用程序在启动时崩溃。

I want to use CUDPP library in my project. I've downloaded sources from project page. Unfortunatly, when I ran "make", there was only static library build. I've looked into Makefile files and haven't found any dynamic lib configuration. I don't want to keep static library with the project - it's totally non-portable way.

My question is: how can I build .so dynamic library of CUDPP, without writing my own Makefile/compiling it manually? Maybe someone already did it?

EDIT: I've replaced "g++" with "g++ -fPIC", "gcc" with "gcc -fPIC" and "nvcc" with "nvcc -Xcompiler -fpic". When I unpack obj files from archive, and link them to shared lib, I've got no error. However, my application crashes at start, when linked with this library.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泡沫很甜 2024-10-12 05:20:13

编译时将标志 -Xcompiler -fpic 传递给 nvcc。如果链接任何 cuda 库,请确保已链接到共享库,否则无法链接它。希望这就是您所需要的。

when you compile pass the flag -Xcompiler -fpic to nvcc. If you link against any cuda libraries make sure you've linked to the shared libs, otherwise you can't link it. Hopefully that's all you need.

夕嗳→ 2024-10-12 05:20:13

您是否还使用 -shared 来创建库?如果存档工作正常,您不需要从存档中提取任何内容。

如果您在可执行文件上运行ldd,它将显示应用程序需要哪些动态链接,并且您可以检查-fPIC等是否正常工作。还要确保 .so 库位于您的 LD_LIBRARY_PATH 上(抱歉,如果这是显而易见的,检查一下没有什么坏处)。

Are you also using -shared to create the library? You shouldn't need to extract anything from an archive if it is working correctly.

If you run ldd on your executable it will show you what dynamic linking is required by the app and you can check that the -fPIC etc. worked correctly. Also make sure that the .so library is on your LD_LIBRARY_PATH (sorry if that's obvious, no harm in checking).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文