How do I use CUDA function in a cpp file?
I must use a CUDA function declared in “cuda.h” (or other cuda libraries), for example cudaMalloc. I know it is simple to do in .cu files but my project is extended, we decide call some CUDA functions in .cpp files.
I saw in the SDK some CUDA functions are called from main.cpp, so why is it not working for me? How do I configure CUDA with Visual Studio 2010?
The error is:
cudaMalloc identifier not found
and
undeclared identifier for size_t types
You can call CUDA API calls from C/C++ compiled with cl.exe, just make sure you include the cuda.h header and link with cudart.lib.
For more detailed instructions on setting up Visual Studio 2010, see this answer.