0

我想使用 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
4

1 回答 1

1

.需要在您LD_LIBRARY_PATH的运行时链接器中才能找到您的共享库。

尝试:

$ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. ./a.out
于 2012-04-06T14:41:38.520 回答