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
- Add a new project to your solution, selecting the NVIDIA CUDA 10.0 Runtime.
- Open the property page for the new project.
- Under Configuration properties, select the 'General' option.
- Under 'Project Defaults' select the configuration type (I chose Static Library). This will automatically set the project target to '.lib'
- 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.
- Build the project.
To test the library perform the following steps.
- Add a new project to your solution, selecting NVIDIA CUDA 10.0 Runtime.
- 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.
- Edit the test project source file Kernel.cu and remove the CUDA wrapper AND the CUDA kernel.
- Add an include that includes the test library include file.
- Build the test project.
- Execute the test project.
My thanks to Saulcpp for pointing me in the right direction.