UbuntuPPA中的CUDA:编译第一个CUDA程序

UbuntuPPA中的CUDA:编译第一个CUDA程序,c,cuda,C,Cuda,我安装了。现在我想测试安装 我抓起了一把椅子。它导入cuda.h和cuda_runtime.h。这是否意味着我需要使用nvcc来编译程序,还是应该使用gcc 当我试图编译时,我得到以下错误。如何告诉编译器在哪里找到必要的库?另外,我自己如何找到这些库?我不确定PPA安装将它们放在哪里,也不确定我应该查找的库的名称 detect_cuda.c:(.text+0x2b): undefined reference to `cudaGetDeviceCount' detect_cuda.c:(.text

我安装了。现在我想测试安装

我抓起了一把椅子。它导入cuda.h和cuda_runtime.h。这是否意味着我需要使用nvcc来编译程序,还是应该使用gcc

当我试图编译时,我得到以下错误。如何告诉编译器在哪里找到必要的库?另外,我自己如何找到这些库?我不确定PPA安装将它们放在哪里,也不确定我应该查找的库的名称

detect_cuda.c:(.text+0x2b): undefined reference to `cudaGetDeviceCount'
detect_cuda.c:(.text+0x30): undefined reference to `cudaGetLastError'
detect_cuda.c:(.text+0x47): undefined reference to `cudaGetErrorString'
detect_cuda.c:(.text+0xba): undefined reference to `cudaGetDeviceProperties'

添加-lcudart按照Anycom在评论中的建议工作

nvcc -lcudart detect_cuda.cu

-lcudart
添加到链接器/编译器但为什么需要这样做?如果我在
nvcc-h
中搜索
lcudart
cudart
我什么也找不到。这看起来像是链接cuda运行时,但为什么需要这样做呢?