在QT上构建CUDA项目会在pch文件上产生错误

时间:2017-08-10 08:54:47

标签: c++ qt compiler-errors precompiled-headers

我不是qmake的专家,我还在尝试在QT上使用CUDA。当我尝试使用CUDA运行它时,它为我的pch文件中的每个QT库提供了一个错误“无法打开包含文件::没有这样的文件或目录”。

我的CUDA和我的pch文件的集成之间是否存在链接?

这是我的.pro文件:

    #-------------------------------------------------
#
# Project created by QtCreator 2017-07-19T14:37:11
#
#-------------------------------------------------

QT       += core gui
QT += opengl
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = GUI_CUDA
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp \
    Console.cpp \
    recorder.cpp \
    LIB_TIFF/tif_aux.c \
    LIB_TIFF/tif_close.c \
    LIB_TIFF/tif_codec.c \
    LIB_TIFF/tif_color.c \
    LIB_TIFF/tif_compress.c \
    LIB_TIFF/tif_dir.c \
    LIB_TIFF/tif_dirinfo.c \
    LIB_TIFF/tif_dirread.c \
    LIB_TIFF/tif_dirwrite.c \
    LIB_TIFF/tif_dumpmode.c \
    LIB_TIFF/tif_error.c \
    LIB_TIFF/tif_extension.c \
    LIB_TIFF/tif_fax3.c \
    LIB_TIFF/tif_fax3sm.c \
    LIB_TIFF/tif_flush.c \
    LIB_TIFF/tif_getimage.c \
    LIB_TIFF/tif_jbig.c \
    LIB_TIFF/tif_jpeg.c \
    LIB_TIFF/tif_jpeg_12.c \
    LIB_TIFF/tif_luv.c \
    LIB_TIFF/tif_lzma.c \
    LIB_TIFF/tif_lzw.c \
    LIB_TIFF/tif_next.c \
    LIB_TIFF/tif_ojpeg.c \
    LIB_TIFF/tif_open.c \
    LIB_TIFF/tif_packbits.c \
    LIB_TIFF/tif_pixarlog.c \
    LIB_TIFF/tif_predict.c \
    LIB_TIFF/tif_print.c \
    LIB_TIFF/tif_read.c \
    LIB_TIFF/tif_strip.c \
    LIB_TIFF/tif_swab.c \
    LIB_TIFF/tif_thunder.c \
    LIB_TIFF/tif_tile.c \
    LIB_TIFF/tif_version.c \
    LIB_TIFF/tif_warning.c \
    LIB_TIFF/tif_win32.c \
    LIB_TIFF/tif_write.c \
    LIB_TIFF/tif_zip.c \
    nvSDIutil.cpp \
    nvSDIin.cpp \
    anccapture.cpp \
    myopenglwidget.cpp \
    readwidget.cpp \

HEADERS  += mainwindow.h \
    recorder.h \
    nvSDIutil.h \
    nvSDIin.h \
    anccapture.h \
    myopenglwidget.h \
    readwidget.h \
    cugl.h


FORMS    += mainwindow.ui \
    readwidget.ui

PRECOMPILED_HEADER = common.h

#Path to glew SDK
GLEW_DIR = "C:\glew\glew-2.0.0-win32\glew-2.0.0"
INCLUDEPATH  += $$GLEW_DIR/include/GL
QMAKE_LIBDIR += $$GLEW_DIR/lib/Release/x64
QMAKE_LIBDIR += $$GLEW_DIR/bin/Release/x64
LIBS += -lglew32 -lglew32s -lopengl32


#Path to SDI_capture SDK
SDI_CAPTURE_DIR = "C:\Program Files (x86)\NVIDIA Corporation\NVIDIA Quadro SDI Video SDK for OpenGL"
# Path to header and libs files
INCLUDEPATH  += $$SDI_CAPTURE_DIR/win/include
INCLUDEPATH  += $$SDI_CAPTURE_DIR/win/include/GL
INCLUDEPATH  += $$SDI_CAPTURE_DIR/win/examples/common
QMAKE_LIBDIR += $$SDI_CAPTURE_DIR/win/lib64
LIBS += -lANCapi -lcutil64 -lcutil64D -lnvapi64 -lNvCpl
LIBS += -lUser32

DISTFILES += cugl.cu

# Cuda sources
CUDA_SOURCES += cugl.cu

CUDA_DIR="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0"

SYSTEM_NAME = Win64         # Depending on your system either 'Win32', 'x64', or 'Win64'
SYSTEM_TYPE = 64            # '32' or '64', depending on your system
CUDA_ARCH = sm_35           # Type of CUDA architecture, for example 'compute_10', 'compute_11', 'sm_10'
NVCC_OPTIONS = --use_fast_math


# include paths
INCLUDEPATH += $$CUDA_DIR/include

# library directories
QMAKE_LIBDIR += $$CUDA_DIR/lib/

# GPU architecture
CUDA_ARCH     = sm_35

# Here are some NVCC flags I've always used by default.
NVCCFLAGS     = --use_fast_math #--compiler-options


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

QMAKE_LFLAGS_RELEASE = /NODEFAULTLIB:msvcrt.lib
QMAKE_LFLAGS_DEBUG   = /NODEFAULTLIB:msvcrt.lib

# Configuration of the Cuda compiler

CONFIG(debug, debug|release){
    # Debug mode
    cuda_d.input = CUDA_SOURCES
    cuda_d.output = ./${QMAKE_FILE_BASE}.obj
    cuda_d.commands = $$CUDA_DIR/bin/nvcc.exe -D_DEBUG -c -Xcompiler $$MSVCRT_LINK_FLAG_DEBUG $$CUDA_INC --machine $$SYSTEM_TYPE -arch=$$CUDA_ARCH
    cuda_d.commands += ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT}
                   #$$LIBS

    cuda_d.dependency_type = TYPE_C
    #cuda.depend_command = $$CUDA_DIR/bin/nvcc -O3 -M $$CUDA_INC $$NVCCFLAGS ${QMAKE_FILE_NAME}
    QMAKE_EXTRA_COMPILERS += cuda_d
}
else{
    # Release mode
    cuda.input = CUDA_SOURCES
    cuda.output = ./${QMAKE_FILE_BASE}.obj
    cuda.commands = $$CUDA_DIR/bin/nvcc.exe -c -Xcompiler $$MSVCRT_LINK_FLAG_RELEASE $$CUDA_INC --machine $$SYSTEM_TYPE -arch=$$CUDA_ARCH
    cuda.commands += ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT}
                   #$$LIBS

    cuda.dependency_type = TYPE_C
    #cuda.depend_command = $$CUDA_DIR/bin/nvcc -O3 -M $$CUDA_INC $$NVCCFLAGS ${QMAKE_FILE_NAME}
    QMAKE_EXTRA_COMPILERS += cuda
}

你有什么想法吗?

EDIT ------ 所以我使用Visual Studio 2015和visual studio 2012在Windows 7 64位上。我有一个版本的QT,它不能用msvc 2015编译,这就是为什么我用32位编译的原因。我改变了我的QT版本以64位编译。 实际上,我得到的错误信息是:

error c1083 cannot open include file: 'QtWidgets/QOpenGLWidget' no such file or directory

---编辑2 我没有在我的cu文件中使用pch来摆脱这个错误。我认为编译器不理解pch。 但我仍然有来自CUDA文件的错误消息:在device_types.h中

C2236: unexpected token 'enum'. Did you forget a ';' ÿ? device_types.h line 61
C2143: syntax error : missing ';' before '{' device_types.h line 62
C2447: '{' ÿ: missing function header (old style format listÿ?) device_types.h line 62

我没有更改这些文件中的任何内容,所以我完全不明白为什么我会收到这些错误? 你们有个主意吗?

0 个答案:

没有答案