在这里我以SDK中自带的deviceQuery.cpp文件为里,利用t.cpp来调用其编译生成的动态链接库。
首先创建一个soTest的文件夹,里面有两个文件deviceQuery.cpp, t.cpp。
deviceQuery.cpp的代码可以参考CUDASDK
t.cpp的源代码如下:
|
#include int cudev(int argc, char** argv); int main(int argc, char ** argv) |
然后在当前目录下输入以下命令:
|
1. g++ -W -Wall -Wimplicit -Wswitch -Wformat -Wchar-subscripts -Wparentheses -Wmultichar -Wtrigraphs -Wpointer-arith -Wcast-align -Wreturn-type -Wno-unused-function -fno-strict-aliasing -I. -I/usr/local/cuda/include -I/home/cuda/NVIDIA_GPU_Computing_SDK/C/common/inc -DUNIX -O2 -o deviceQuery.o -c deviceQuery.cpp |
这样执行 ./t 就可以顺利调用deviceQuery.cpp中的函数了^_^
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/20741649/viewspace-630689/ ,如需转载,请注明出处,否则将追究法律责任。