1、win32控制台应用程序->应用程序类型(dll),附加选项:(空项目,其它去掉,不喜欢生成的东东)。
2、在源文件中添加需要生成的test.cu文件:
#define MYLIBAPI extern "C" __declspec(dllexport) #include"test.h" MYLIBAPI unsigned short a_100[imageN][imageN*imageN] = {}; //后面的{}初始化是必须的,否则会当成声明 MYLIBAPI unsigned short a_120[][2] = { 1, 2, 3, 4 }; MYLIBAPI void Hello(){}
3、在test.cu上右键->属性->项类型(CUDA C/C++),这是必须的,否则不识别cu文件
4、头文件中添加test.h:
#ifdef MYLIBAPI #else #define MYLIBAPI extern "C" __declspec(dllimport) #endif #define imageM 256 #define imageN 256 MYLIBAPI void Hello(); MYLIBAPI unsigned short a_100[][imageN*imageN]; MYLIBAPI unsigned short a_120[][2];
ok!