Linker issue with CUDA API libraries
Solved
General and Desktop
-
Hi! I want to add
Nvidia CUDA API
toQt
(OS: Windows | Qt 5.7.1).I have included:
.pro file INCLUDEPATH += "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0\\include" win32 { contains(QMAKE_TARGET.arch, x86_64) { LIBS += "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0\\lib\\x64\\cudadevrt.lib" } else { LIBS += "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0\\lib\\Win32\\cudadevrt.lib" } } test.h file #include <cuda_runtime.h>
I get errors in
test.cpp
:Screenshot:
I have test it in
Visual Studio 2015
as console project and it works, but not inQt
.How to fix it? Thanks in advance.
-
That's not how you pass libraries to the linker. Change this:
LIBS += "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0\\lib\\x64\\cudadevrt.lib"
to
LIBS += -L"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64" -lcudadevrt
That's
-L
for the path and-l
(lowercase L) for the library name without the extension.
After that re-run qmake (menu Build->Run qmake). -
I have changed to:
INCLUDEPATH += "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0\\include" win32 { contains(QMAKE_TARGET.arch, x86_64) { LIBS += -L"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64" -lcudadevrt } else { LIBS += -L"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/Win32" -lcudadevrt } }
Run clean/run qmake/build but the errors still exists.
-
I have found the bug and fixed. Thanks.
-
@chris-kawa
Please tell me how to solved this issue..I am troubling for solving this issue on windows platform -
Can you provide some more information?
- Which compiler?
- 32 or 64 bit?
- Can you show your .pro file and the actual linker command from the Compile Output?