Unsolved Add Cuda libs to QT
-
Hello,
I found in web many examples how to link NVIDIA CUDA to QtProject (Mingw or MSVC 64 bit), but none work correctly for me. Maybe someone know how to do this?
Kking
My last: .pro file looks like that:
QT += core QT -= gui TARGET = QtCuda CONFIG += console CONFIG -= app_bundle TEMPLATE = app SOURCES += main.cpp \ cuda_code.cu # project build directories DESTDIR = $$PWD OBJECTS_DIR = $$DESTDIR/obj # C++ flags QMAKE_CXXFLAGS_RELEASE =-O3 # Cuda sources CUDA_SOURCES += cuda_code.cu # Path to cuda toolkit installb C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\lib\x64 CUDA_DIR = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v7.5" # Path to header and libs files INCLUDEPATH += $$CUDA_DIR/include QMAKE_LIBDIR += $$CUDA_DIR/lib/x64 SYSTEM_TYPE = 64 # '32' or '64', depending on your system # libs used in your code LIBS += -lcuda -lcudart # GPU architecture CUDA_ARCH = sm_50 # Here are some NVCC flags I've always used by default. NVCCFLAGS = --use_fast_math # Prepare the extra compiler configuration (taken from the nvidia forum - i'm not an expert in this part) CUDA_INC = $$join(INCLUDEPATH,'" -I"','-I"','"') # MSVCRT link option (static or dynamic, it must be the same with your Qt SDK link option) MSVCRT_LINK_FLAG_DEBUG = "/MDd" MSVCRT_LINK_FLAG_RELEASE = "/MD" # Tell Qt that we want add more stuff to the Makefile QMAKE_EXTRA_COMPILERS += cuda # Configuration of the Cuda compiler CONFIG(debug, debug|release) { # Debug mode cuda_d.input = CUDA_SOURCES cuda_d.output = $$OBJECTS_DIR/${QMAKE_FILE_BASE}.obj cuda_d.commands = $$CUDA_DIR/bin/nvcc.exe -D_DEBUG $$NVCC_OPTIONS $$CUDA_INC $$LIBS --machine $$SYSTEM_TYPE \ -arch=$$CUDA_ARCH -c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME} -Xcompiler $$MSVCRT_LINK_FLAG_DEBUG cuda_d.dependency_type = TYPE_C QMAKE_EXTRA_COMPILERS += cuda_d } else { # Release mode cuda.input = CUDA_SOURCES cuda.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}.obj cuda.commands = $$CUDA_DIR/bin/nvcc.exe $$NVCC_OPTIONS $$CUDA_INC $$LIBS --machine $$SYSTEM_TYPE \ -arch=$$CUDA_ARCH -c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME} -Xcompiler $$MSVCRT_LINK_FLAG_RELEASE cuda.dependency_type = TYPE_C QMAKE_EXTRA_COMPILERS += cuda } And errors: [Image](https://snag.gy/MdxNzs.jpg)
-
Hi and welcome to devnet,
IIRC, the cuda-z project has working implementation of Cuda + Qt. You should find there some inspiration.
Hope it helps