Problems with exporting DLL in VS2010 (CUDA)

為{幸葍}努か 提交于 2020-01-30 08:07:44

问题


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);

    }

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 : 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.

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 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


回答1:


I see cudart.lib in your linker commands, but not cufft.lib. Probably the source of the problem.

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.



来源:https://stackoverflow.com/questions/6511714/problems-with-exporting-dll-in-vs2010-cuda

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!