calling CUDA from C++ in MSVC

Good Afternoon,

I’m trying to slowly port a homebrew c++ code of mine to CUDA and I’d like to move one piece at a time. This means I’d have to call CUDA from C++.

I know it’s possible, I’ve seen the example in the SDK, and I know how to do extern “C”, etc. However how do I set up a MSVC solution to accomodate this?

I’ve been using the CUDA VS Wizard to create new project and it works great. I’m not sure what I need to do to tweak the build order, etc.

If I try right now to compile a mixed CUDA/C++ project, nvcc tells me it’s missing main, and it never gets to compiling the C++ code.

Thank you,

Philip

There are many ways to do this. One of the simpler ones is to just compile .cu files into object files and let VS do all the linking. Add a file to the project, go to its properties, and configure the custom build step with a command-line “nvcc -c …” (no quotes, … is your file and whatever other options you need).

Paulius

Thanks. I wound up getting it working.

Appreciate the advice.

philip