QMAKE adding extra quotations in lib path of make file

≡放荡痞女 提交于 2019-12-24 00:37:16

问题


After many obscure errors (at least to me), I discovered while trying to set up a QtCreator project file for use with CUDA that there were some extra quotation marks being put in the LIBS definition of the Makefile.Debug and Makefile.Release files.

LIBS          = /LIBPATH:"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\lib\x64" ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\lib\x64"\cuda.lib" ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\lib\x64"\cudart.lib" /LIBPATH:C:\Qt\5.2.1\msvc2012_64_opengl\lib C:\Qt\5.2.1\msvc2012_64_opengl\lib\Qt5Cored.lib 

If you look closely at the second entry in the LIBPATH, you'll see an extra quotation mark in front of the C:. You'll also see an extra quotation mark in the middle of that string, right after x64. This anomaly happens for both entries for the CUDA libraries. If I go into this makefile and manually correct it (removing the extra quotes), the project builds and runs without errors.

So, I'm wondering how to set up the project file to correct this. It's getting old having to go back to the makefile for manual fixes.

For reference, here is my entire project file.

QT       += core
QT       -= gui

TARGET = QtCuda
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app

SOURCES += main.cpp

HEADERS += cuda/vectorAddition.h

#OTHER_FILES += cuda_code.cu

# project build directories
CONFIG(debug, debug|release) {
    # Debug mode
DESTDIR     = $$PWD/debug
}
else {
    # Release mode
DESTDIR     = $$PWD/release
}

OBJECTS_DIR = $$DESTDIR/obj

# Cuda sources
CUDA_SOURCES += cuda/vectorAddition.cu

# Path to cuda toolkit install
CUDA_DIR      = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v7.0"

# Path to header and libs files
INCLUDEPATH  += $$CUDA_DIR/include
QMAKE_LIBDIR += $$CUDA_DIR/lib/x64

# '32' or '64', depending on your system
SYSTEM_TYPE = 64

# 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"


# 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 = $$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
}

HEADERS += \
    cuda/vectorAddition.h

回答1:


The bug is reproduced on Qt 5.3.0, Qt 5.3.2 if there is at least one space in library path. It works as expected with Qt 5.5.1.

So, there are two options:

  • upgrade Qt to 5.5.1 (some earlier version also may work);
  • move libraries to directories with full path without spaces.


来源:https://stackoverflow.com/questions/33422028/qmake-adding-extra-quotations-in-lib-path-of-make-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!