So far I have set up a small Visual Studio 2010 project with some dummy classes and tried to compile it as executable. This worked. When I try to compile it as static lib, I get the error message
LINK : fatal error LNK1181: Input file "Debug\TestLib.device-link.obj" cannot be opened.
Then I set up my own MakeFile. Then I have been able to build a lib, but when I try to link it to an executable, I get following error for nearly every method I have written:
main.obj : error LNK2019: Unresolved external symbol ""public : unsigned int __cdecl TestLoader::getCount(void)" (?getCount@TestLoader@@QEAAIXZ) " in Function ""class TestLoader * __cdecl getModel(char const *)" (?getModel@@YAPEAVTestLoader@@PEBD@Z)".
Is there a solution for this, or is the linker not able to link device functions to static libs?
I created a very small test application and tried to build it using the cuda compiler.
To make it short: On Linux the compilation and execution works as expected. On Windows the compilation works but I get an “invalid device function” when executing the application.
The problem seems that the device code is not linked properly into the created library.
Is there a solution for this problem available or is it a bug in the current Cuda release?
Please tell me nvcc is able to compile more than one file. If not, I guess the workaround is to put all cuda code in a single file, which means it’s going to be several thousand lines long.
The .cuh files are the problem. They simply don’t work, so remove them from your project and only use .cu files.
If you are getting multiple symbol definition linker errors, put #pragma once at the top of your .cu files. Also, be sure to mark all functions that aren’t class member functions as static. Doing both of those solved my problem and I am now able to build my project with many .cu files.
But has anyone figured out the initial question?! I am trying to make a fully working project under Linux also work with Windows 7 and VisualStudio 2010. No luck so far. I need to use separate compilation/linking due to some Dynamic Parallelism code, which requires this.
I also get the “LINK : fatal error LNK1181: Input file “DebugTestLib.device-link.obj” cannot be opened.” error message.
I have not set up my own Makefile, would really like this to work with the IDE.