CUDA: Device link not enabled for library target in VS2017
- CMake: 3.10.0
- CUDA: 9.0
- OS: Windows 10
- VS: 2017
- Testing project: https://github.com/chaosink/cupix
Some facts:
Library targets don't enable device link (CUDA Linker
option in VS) no matter CUDA_SEPARABLE_COMPILATION
is ON
or OFF
.
Executable targets always enable device link no matter CUDA_SEPARABLE_COMPILATION
is ON
or OFF
.
Problem:
For the example project in the article, the library target particle
without device link is OK, because the executable target particle_test
also has .cu
files. So nvcc will be called to link particle
and particle_test
with -dlink
.
However, if the executable target particle_test
doesn't have .cu
files (for example the tesing project), nvcc will not be called so the library particle
will not do device link. This will cause the common error __cudaRegisterLinkedBinary
in the final link.
For the testing project, I have to enable device link manually for the library target in VS CUDA Linker
.