我想使用 nVIDIA 编译器生成一个共享库,供我的 GNU 编译器链接。一切顺利,直到运行时。以下是详细内容。谢谢!
主.cpp:
#include <iostream>
using namespace std;
void fcudadriver();
int main()
{
cout<<"Maine "<<endl;
fcudadriver();
return 0;
}
测试.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