CUDA CUDPP .so 构建
我想在我的项目中使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编译时将标志
-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.您是否还使用
-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 yourLD_LIBRARY_PATH
(sorry if that's obvious, no harm in checking).