0
我想使用nVIDIA编译器为我的GNU编译器生成一个共享库来链接。一切都很顺利,直到运行。以下是详细信息。谢谢!使用nVIDIA编译器为我的GNU编译器生成共享库时运行时错误链接
main.cpp中:
#include <iostream>
using namespace std;
void fcudadriver();
int main()
{
cout<<"Maine "<<endl;
fcudadriver();
return 0;
}
test.cu:
__global__ void fcuda()
{
}
void fcudadriver()
{
fcuda<<<1,1>>>();
}
编译:
nvcc --compiler-options '-fPIC' -o libtest.so --shared test.cu
g++ main.cpp -L. -ltest
运行:
./a.out
个结果:
./a.out: error while loading shared libraries: libtest.so: cannot open shared object file: No such file or directory
它的工作原理!谢谢! – 2012-04-06 14:51:55
这与g ++无关。运行时链接程序在由/etc/ld.so.conf和环境变量LD_LIBRARY_PATH控制的一组路径中查找共享库。这就是Linux上的工作原理。 (有一些关于setuid程序的注意事项。)请参阅man ld.so – Mat 2012-04-06 14:56:04