CUDA 6.0 Dynamic Parallelism: getting error LNK 1169 when linking multiple user static libraries tha

Good day. I am working on my PhD developing parallel metaheuristics in CUDA for optimization of Smart-Grids and I am facing a Visual Studio project configuration problem that I can’t resolve. I am using Visual Studio 2012 Pro with the production release version of CUDA 6.0.

  1. I can create a CUDA project in Visual Studio that uses Dynamic Parallelism (I use -rdc=true, compute50,sm_50, MT runtime library and added cudadevrt.lib to the additional link libraries). I can compile, run and Dynamic Parallelism works.

  2. I can create a user static library (for example: dynamic_parallelism.lib) that uses CUDA Dynamic Parallelism and call this library from another project. Everything still works.

  3. Now, I am creating a second user static library that uses CUDA (for example: dynamic_parallelism_2.lib). My project now calls functions from the first user static library (dynamic_parallelism.lib) that in turn calls functions from the second user static library (dynamic_parallelism_2.lib). Everything works if I don’t use Dynamic Parallelism (and only add cudart.lib in the linker libraries), but when I use dynamic parallelism (and add cudadevrt.lib and cudart.lib in my two libraries) I get a linker error LNK1169. It seems like cudadevrt.lib is causing the problem. Any idea how I could solve this?

I wasted many hours on that one and I am ready to try anything. Don’t hesitate to propose a fix. Also, if you want a simple Visual Studio 2012 solution with the 3 example projects that illustrate the problem, send me a message and I can email you the VS solution. Thank you very much.

3>  cudadevrt.lib
3>  cudart.lib
3>  kernel32.lib
3>  user32.lib
3>  gdi32.lib
3>  winspool.lib
3>  comdlg32.lib
3>  advapi32.lib
3>  shell32.lib
3>  ole32.lib
3>  oleaut32.lib
3>  uuid.lib
3>  odbc32.lib
3>  odbccp32.lib
3>dynamic_parallelism_lib.lib(dynamic_parallelism_lib_2.device-link.obj) : error LNK2005: __cudaRegisterLinkedBinary_66_tmpxft_000008f4_00000000_11_cuda_device_runtime_compute_50_cpp1_ii_5f6993ef already defined in dynamic_parallelism_lib.lib(dynamic_parallelism_lib.device-link.obj)
3>D:\ecole\Workspace\visual_studio_2012_projects\vincent_doctorat\x64\Debug\dynamic_parallelism_test.exe : fatal error LNK1169: one or more multiply defined symbols found

If you are interested to visualize the problem, I created an example solution with 3 projects (the main app and the two static libraries). It is built in Visual Studio 2012 Pro on Windows 8.1 x64 and CUDA 6.0. Please have a look if you think you can help me. Thank you in advance. (146 KB)