Visual Studio CUDA library project template?

Hello All-

This question steams from an earlier question that I posted asking for information as to how to compile and link CUDA libraries that in turn can be linked with other standard (Non-CUDA) C++ libraries. I received some very useful help, which helped me better understand the CUDA compile and link process, however it was very command line orientated. I was hoping someone out there might have already created a project template that would simplify the process while working within the Visual Studio IDE. Yes, I know, I should not lean on the IDE, but sometimes tools like IDEs are great time savers.

I would greatly appreciate it if anyone out there knows of a CUDA library project template that can be used for VS 2017.

Thanks,

Jim

In a different thread, I had asked a similar question. It turns out that it is quite easy to create a library project using the executable project template that is included when you install the CUDA toolkit. Once created I suspect you can easily export the created project template and use it for future CUDA library projects, have not tried that yet, but it should work. To create the CUDA library project follow the steps below:

The steps below assume that you have already installed the CUDA toolkit. This example assumes the use of the CUDA Tookkit 10.0

  1. Add a new project to your solution, selecting the NVIDIA CUDA 10.0 Runtime.
  2. Open the property page for the new project.
  3. Under Configuration properties, select the 'General' option.
  4. Under 'Project Defaults' select the configuration type (I chose Static Library). This will automatically set the project target to '.lib'
  5. Edit the auto-generated cuda source file (Kernel.cu) and remove the main function. For this example, keep the CPP wrapper function 'addWithCuda' in the file, this is the function that will call the CUDA kernel.
  6. Build the project.

To test the library perform the following steps.

  1. Add a new project to your solution, selecting NVIDIA CUDA 10.0 Runtime.
  2. Add a reference to the created CUDA library project to the new test project by right clicking on references under the new test project and selecting the CUDA library project.
  3. Edit the test project source file Kernel.cu and remove the CUDA wrapper AND the CUDA kernel.
  4. Add an include that includes the test library include file.
  5. Build the test project.
  6. Execute the test project.

My thanks to Saulcpp for pointing me in the right direction.

Jim