gcc 和 CUDA 问题
你好,
我已经编译了一个 CUDA 共享库,但无法将它与使用它的主程序链接。我正在用 gcc 编译主程序。
编码:
简单的main.c
#include <stdio.h>
#include <stdlib.h>
void fcudadriver();
int main()
{
printf("Main \n");
fcudadriver();
return 0;
}
测试.cu
__global__ void fcuda()
{
}
void fcudadriver()
{
fcuda<<<1,1>>>();
}
我将 test.cu 编译为 --> 它可以工作
nvcc --compiler-options '-fPIC' -o libtest.so --shared test.cu
我将 simplemain.c 编译为 ---> 它给出了错误:(
gcc simplemain.c -L. -ltest
/tmp/ccHnB4Vh.o:simplemain.c:function main: error: undefined reference to 'fcudadriver'
collect2: ld returned 1 exit status