在VS2010(CUDA)中导出DLL的问题 [英] Problems with exporting DLL in VS2010 (CUDA)
问题描述
构建DLL解决方案时遇到麻烦.我正在制造用于LabVIEW 2010的DLL,以便具有CUDA功能.但是,我要导出的每一个函数都收到链接器错误LNK2019.
I have having trouble when building the DLL solution. I am making the DLL for use in LabVIEW 2010 in order to have CUDA capabilities. However, I am getting linker error LNK2019 on every single one of my functions I want exported.
#include "LVCUDA.h"
#include "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include\cufft.h"
#include "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include\cuda.h"
#include <windows.h>
#include <string.h>
#include <ctype.h>
BOOL WINAPI DllMain (
HANDLE hModule,
DWORD dwFunction,
LPVOID lpNot)
{
return TRUE;
}
__declspec(dllexport) cufftHandle LVcufftPlan2D(int Xsize, int Ysize){
cufftHandle plan;
cufftPlan2d(&plan, Xsize, Ysize, CUFFT_C2C);
return plan;
}
__declspec(dllexport) void LVexecute(cufftHandle plan, cufftComplex *data, int direction){
if (direction == 1) cufftExecC2C(plan, data, data, CUFFT_INVERSE);
else cufftExecC2C(plan, data, data, CUFFT_FORWARD);
}
__declspec(dllexport) void LVdestroy(cufftHandle plan){
cufftDestroy(plan);
}
__declspec(dllexport) void LV_cudaFree(CUdeviceptr ptr){
cuMemFree(ptr);
}
__declspec(dllexport) void LV_cudaMalloc(CUdeviceptr *ptr, int cnt){
cuMemAlloc(ptr, cnt);
}
__declspec(dllexport) void LV_cudaMemcopy(CUdeviceptr src, CUdeviceptr dst, int cnt){
cuMemcpy(dst, src, cnt);
}
我已经将构建自定义更改为CUDA 4.0,因此所有库都包含在依赖项中.但是,我仍然收到以下错误:
I have already changed the build customization to CUDA 4.0, so all the libraries are included in the dependencies. However, I still get the following error:
1> LVCUDA.obj:错误LNK2019:函数_LVcufftPlan2D中引用的未解析的外部符号_cufftPlan2d @ 16
1>LVCUDA.obj : error LNK2019: unresolved external symbol _cufftPlan2d@16 referenced in function _LVcufftPlan2D
当我尝试构建解决方案时.
when i try to build the solution.
我想知道还有什么导致链接器不断抛出未解决的外部符号错误.
I was wondering what else I am missing that is causing the linker to keep throwing unresolved external symbol errors.
从CUDA生成的自动命令行为:
The automatic command line generated from CUDA was:
/OUT:"C:\ VC Projects \ CUDA \ Debug \ CUDA.dll"/INCREMENTAL/NOLOGO/LIBPATH:"C:\ Program Files \ NVIDIA GPU Computing Toolkit \ CUDA \ v4.0 \ bin"/LIBPATH:"C:\ Program Files \ NVIDIA GPU计算工具包\ CUDA \ v4.0 \ lib \ x64"/LIBPATH:"C:\ Program Files \ NVIDIA GPU计算工具包\ CUDA \ v4.0 \ lib \ Win32"/DLL"cudart.lib""kernel32.lib""user32.lib""gdi32.lib""winspool.lib""comdlg32.lib""advapi32.lib""shell32.lib""ole32.lib""oleaut32.lib""uuid.lib""odbc32.lib""odbccp32.lib"/MANIFEST/ManifestFile:"Debug\CUDA.dll.intermediate.manifest"/ALLOWISOLATION/MANIFESTUAC:" level ='asInvoker'uiAccess ='false'"/DEBUG/PDB:"C:\ VC Projects \ CUDA \ Debug \ CUDA.pdb"/SUBSYSTEM:WINDOWS/PGD:"C:\ VC Projects \ CUDA \ Debug \ CUDA.pgd"/TLBID:1/DYNAMICBASE/NXCOMPAT/MACHINE:X86/ERRORREPORT:QUEUE
/OUT:"C:\VC Projects\CUDA\Debug\CUDA.dll" /INCREMENTAL /NOLOGO /LIBPATH:"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin" /LIBPATH:"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\lib\x64" /LIBPATH:"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\lib\Win32" /DLL "cudart.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MANIFEST /ManifestFile:"Debug\CUDA.dll.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\VC Projects\CUDA\Debug\CUDA.pdb" /SUBSYSTEM:WINDOWS /PGD:"C:\VC Projects\CUDA\Debug\CUDA.pgd" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE
推荐答案
我在链接器命令中看到了cudart.lib,但没有看到cufft.lib.可能是问题的根源.
I see cudart.lib in your linker commands, but not cufft.lib. Probably the source of the problem.
我不知道从CUDA生成的自动命令行"是什么意思,所以我不确定您将如何进行更改.我只是在VS Linker属性中手动添加Cuda库.
I don't know what 'automatic command line generated from CUDA' means so I'm not sure how you will need to change things. I just add Cuda libs manually in VS Linker properties.
这篇关于在VS2010(CUDA)中导出DLL的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!