Application that uses CUDA DLL

Hi everybody!

I have created a CUDA .dll file in Visual Studio 2010. I have the .lib file also.
Now I’m trying to call a function contained the .dll file from another code (the application code).

My application code is the following, it is very simple:

#include “stdafx.h”
#include <cuda_runtime_api.h>

__declspec(dllimport) void ForwardPropagation();

int _tmain(int argc, _TCHAR* argv)
{

printf("Calling main... \n");
ForwardPropagation();
printf("\nDONE! \n");

return 0;

}

When I try to compile it, it appears the following error in the output section in VS 2010:

1>cuda_vector_app.obj : error LNK2019: unresolved external symbol “__declspec(dllimport) void __cdecl ForwardPropagation(void)” (_imp?ForwardPropagation@@YAXXZ) referenced in function wmain
1>C:\Users\Student3\Documents\cuda_vector_app_3\x64\Debug\cuda_vector_app.exe : fatal error LNK1120: 1 unresolved externals

I’m not sure why this error is appearing because I have implemented another code under the same premises and I don’t have problems with it. I don’t know why for this specific case the compilation presents this error.

All comments and suggestions will be appreciated.

Arturo V.

Are you trying to use static or dynamic loading? (Have you put the .lib in the “input” field of the linked for compilation?)
Are you exposing a header file associated with the library that would have function signatures?

From what you have shown, I see no way for the linker to know how and where ForwardPropagation is implemented.

In a general way, there is nothing different between a “regular” DLL and a CUDA DLL, so if you know how to work with one, you know how to work with the other.

I think it is a static loading. I specified the path of my .lib file before compilation.

I changed ‘ForwardPropagation’ by ‘main’ in my application and in my DLL and everything went OK… every time I execute the .exe of the application, the DLL is invoked. I’m not sure why this change made the difference.

What do you think?