I'm porting a GPU application to Windows, using MSVC, which doesn't seem to play very nice with NVCC. I have separated the compiling and linking phases. nvcc will pre-process only the cuda files:
nvcc -dc -ccbin cl somefile.cu
and cl will compile everything else:
cl anotherfile.c
This separation was necessary, since many MSVC flags (excluded here) didn't jive with nvcc's wrapping of cl.exe (a related symptom here).
With compiling done, there are two ways I can do the linking.
- use
nvccto link only the CUDA device code, and then uselink.exeto link everything, as per this guide.
As hard as I tried, I could not get link to find the CUDA headers, nor could I find any doc about how to point link to the cudart library. If only it were as easy as their g++ example!
- let
nvccdo all the linking.
According to the doc however, there is "no option" to jump to the linking stage. So when I try to link everything, using...
nvcc somefile.o anotherfile.o -o app.exe
I get some warnings from cl!
cl : Command line warning D9024 : unrecognized source file type 'somefile.o', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'anotherfile.o', object file assumed
Naturally, nvcc assumes these object files are source code and sends them to cl, because the doc includes:
Note that nvcc does not make any distinction between object, library or resource files.
Of course cl is complaining - these object files should be passed straight to the linker. I know link does eventually get invoked, beause I pass it some unrelated arguments with -Xlinker. After these warnings, app.exe is indeed compiled.
Despite the doc indicating there is no linker phase argument, how can I force nvcc to just link the objects, and not incorrectly pass them to cl? There is no way to suppress these warnings (at least not without being condemned by the stackoverflow community).