LNK1104: cannot open cuda.lib // CUDA 6.5 on Qt creator



  • Hello there,

    I want to use my gtx 980 ti for cuda FFT programming.
    My project should be coded on Win32 to link various libraries.
    So, I installed CUDA 6.5 integrated with visual studio 2010.
    My framework for my application is Qt Creator 4.3 with Qt library 4.8.6.

    When I compiled my program I got the following error:
    LINK : fatal error LNK1104: cannot open file 'cuda.lib'
    jom: D:\sdkk_beta_cpy\demo_7\build-qt-Desktop-Debug\Makefile.Debug [debug\QtCuda.exe] Error 1104
    jom: D:\sdkk_beta_cpy\demo_7\build-qt-Desktop-Debug\Makefile [debug] Error 2

    how can I fix it?

    Best,

    ===============================================================================
    QT += core

    TARGET = QtCuda
    CONFIG += console
    CONFIG -= app_bundle
    TEMPLATE = app

    HEADERS +=
    1.h
    2.h
    3.h \

    SOURCES +=
    1.cpp
    main.cpp
    2.cpp
    3.cpp \

    FORMS +=
    myUI.ui \

    RESOURCES +=
    myApp.qrc

    OTHER_FILES +=
    res/u.ico
    res/stop.png
    res/run.png
    res/init.png \

    INCLUDEPATH += ../../inc/
    INCLUDEPATH += ../../../

    //# CUDA settings <-- may change depending on your system
    CUDA_SOURCES += "D:/sdkk_beta_cpy/demo_7/qt/pitchhilbert.cu"
    "D:/sdkk_beta_cpy/demo_7/qt/pitchtable.cu"
    CUDA_SDK = "D:/Programes/NVIDIA/NVIDIA GPU Computing SDK 4.0/C" # Path to cuda SDK install
    CUDA_DIR = "D:/Programes/NVIDIA/CUDA6.5/toolkit" # Path to cuda toolkit install
    SYSTEM_NAME = Win32 # Depending on your system either 'Win32', 'x64', or 'Win64'
    SYSTEM_TYPE = 64 # '32' or '64', depending on your system
    CUDA_ARCH = sm_20 # Type of CUDA architecture, for example 'compute_10', 'compute_11', 'sm_10'
    NVCC_OPTIONS = --use_fast_math

    //# include paths
    //#INCLUDEPATH += $$CUDA_DIR/include
    //# $$CUDA_SDK/common/inc/
    //# $$CUDA_SDK/../shared/inc/
    INCLUDEPATH += "D:/Programes/NVIDIA/CUDA6.5/toolkit/include"
    INCLUDEPATH += "D:/Programes/NVIDIA/NVIDIA GPU Computing SDK 4.0/C/common/lib/Win32"
    INCLUDEPATH += "D:/Programes/NVIDIA/NVIDIA GPU Computing SDK 4.0/shared/inc"

    //# library directories
    //#QMAKE_LIBDIR += $$CUDA_DIR/lib/$$SYSTEM_NAME
    //# $$CUDA_SDK/common/lib/$$SYSTEM_NAME
    //# $$CUDA_SDK/../shared/lib/$$SYSTEM_NAME
    QMAKE_LIBDIR += "D:/Programes/NVIDIA/CUDA6.5/toolkit/include"
    QMAKE_LIBDIR += "D:/Programes/NVIDIA/NVIDIA GPU Computing SDK 4.0/C/common/lib/Win32"
    QMAKE_LIBDIR += "D:/Programes/NVIDIA/NVIDIA GPU Computing SDK 4.0/shared/lib/Win32"

    //# Add the necessary libraries
    //#INCLUDEPATH += "D:/Programes/NVIDIA/CUDA6.5/toolkit/lib/Win32"
    LIBS += -lcuda -lcudart -lcufft

    //# The following library conflicts with something in Cuda
    //#QMAKE_LFLAGS_RELEASE = /NODEFAULTLIB:msvcrt.lib
    //#QMAKE_LFLAGS_DEBUG = /NODEFAULTLIB:msvcrtd.lib

    //# The following makes sure all path names (which often include spaces) are put between quotation marks
    CUDA_INC = $$join(INCLUDEPATH,'" -I"','-I"','"')

    //# Configuration of the Cuda compiler
    CONFIG(debug, debug|release) {
    //# Debug mode
    cuda_d.input = CUDA_SOURCES
    cuda_d.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}_cuda.o
    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}
    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}_cuda.o
    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}
    cuda.dependency_type = TYPE_C
    QMAKE_EXTRA_COMPILERS += cuda
    }


  • Moderators

    @gj21kr
    where do you have this qmake code from?
    QMAKE_LIBDIR should actually be LIBS (use -L to specify the path)



  • @raven-worx

    Thanks! I fixed it


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.