How to link DLL device code?

Hi,
There is a dll file that contains a host device function. I want to call it in another project’s kernel, but I have an error: MSB3721

The command ““C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\bin\nvcc.exe” -dlink -o x64\Debug\cuda_dll_test.device-link.obj -Xcompiler “/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -LC:\Users\user001\source\repos\dll\x64\Debug -L"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\lib\x64” dll.lib 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 -gencode=arch=compute_35,code=sm_35 -G --machine 64 x64\Debug\kernel.cu.obj” exited with code 255.

If I call it in host code, it works fine. I read about Separate Compilation and Linking of CUDA C++ Device Code:

https://devblogs.nvidia.com/separate-compilation-linking-cuda-device-code/
https://devtalk.nvidia.com/default/topic/792656/linking-device-code/

and I found a similar topic:

https://devtalk.nvidia.com/default/topic/832995/create-dll-under-visual-studio-2010/?offset=2

but i can’t solve my problem whit dll.

Thanks

Device linking doesn’t work across a dynamic/shared library boundary. This is mentioned in the nvcc manual.

In general, when creating a DLL, I would recommend using an interface across the DLL that consists of ordinary C/C++ functions. A DLL can certainly contain CUDA code, but use wrappers so that those functions can be called across the interface.

Understood, thanks for your response Bob :)