- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我尝试在 Qt 5.2 和 MSVC2012 环境下编译一个 cuda 文件。在开始我的项目之前,我仔细阅读了问题并回复:Compiling Cuda code in Qt Creator on Windows .但是即使我简单地复制代码并在qt中生成2个文件,仍然会弹出一些错误
/main.cpp
/vectorAddition.cu
错误是:
error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MTd_StaticDebug' in vectorAddition_cuda.o
我完全不知道如何修复这个错误。我在网上阅读了一些关于修复 MSVC2012 中的不匹配问题的文章。但很少有人提到如何在 Qt .pro 文件中做到这一点。有没有人碰巧遇到这个问题?
我这里也附上了pro文件(根据我自己的目录稍作修改)
#-------------------------------------------------
#
# Project created by QtCreator 2014-10-05T13:22:19
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled
TEMPLATE = app
SOURCES += main.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
# Define output directories
DESTDIR = debug
OBJECTS_DIR = debug/obj
CUDA_OBJECTS_DIR = debug/obj
# Source files
# This makes the .cu files appear in your project
OTHER_FILES += vectorAddition.cu
# CUDA settings <-- may change depending on your system
CUDA_SOURCES += vectorAddition.cu
CUDA_SDK = "C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 4.0/C" # Path to cuda SDK install
CUDA_DIR = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5" # Path to cuda toolkit install
SYSTEM_NAME = Win32 # Depending on your system either 'Win32', 'x64', or 'Win64'
SYSTEM_TYPE = 32 # '32' or '64', depending on your system
CUDA_ARCH = sm_30 # 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/
# library directories
QMAKE_LIBDIR += $$CUDA_DIR/lib/$$SYSTEM_NAME \
$$CUDA_SDK/common/lib/$$SYSTEM_NAME \
$$CUDA_SDK/../shared/lib/$$SYSTEM_NAME
# Add the necessary libraries
LIBS += -lcuda -lcudart
# 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"
# 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
}
这是我的日志
13:58:14: Running steps for project untitled...
13:58:14: Configuration unchanged, skipping qmake step.
13:58:14: Starting: "C:\Qt\Qt5.2.0\Tools\QtCreator\bin\jom.exe"
C:\Qt\Qt5.2.0\Tools\QtCreator\bin\jom.exe -f Makefile.Debug
"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\bin\nvcc.exe" -D_DEBUG --use_fast_math -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5/include" -I"C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 4.0/C/common/inc/" -I"C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 4.0/C/../shared/inc/" -lcuda -lcudart --machine 32 -arch=sm_30 -c -o debug\obj\vectorAddition_cuda.obj ..\untitled\vectorAddition.cu
vectorAddition.cu
echo 1 /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ 24 /* RT_MANIFEST */ "debug\\untitled.exe.embed.manifest">debug\untitled.exe_manifest.rc
if not exist debug\untitled.exe if exist debug\untitled.exe.embed.manifest del debug\untitled.exe.embed.manifest
if exist debug\untitled.exe.embed.manifest copy /Y debug\untitled.exe.embed.manifest debug\untitled.exe_manifest.bak
link /NOLOGO /DYNAMICBASE /NXCOMPAT /NODEFAULTLIB:msvcrtd.lib /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST /MANIFESTFILE:debug\untitled.exe.embed.manifest /OUT:debug\untitled.exe @C:\Users\JYOU\AppData\Local\Temp\untitled.exe.4748.3744.jom
main.obj : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MTd_StaticDebug' in vectorAddition_cuda.obj
moc_mainwindow.obj : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MTd_StaticDebug' in vectorAddition_cuda.obj
LINK : fatal error LNK1181: cannot open input file 'C:\Program.obj'
jom: C:\Qt\Qt5.2.0\Tools\QtCreator\bin\build-untitled-Desktop_Qt_5_2_0_MSVC2012_32bit-Debug\Makefile.Debug [debug\untitled.exe] Error 1181
jom: C:\Qt\Qt5.2.0\Tools\QtCreator\bin\build-untitled-Desktop_Qt_5_2_0_MSVC2012_32bit-Debug\Makefile [debug] Error 2
13:58:18: The process "C:\Qt\Qt5.2.0\Tools\QtCreator\bin\jom.exe" exited with code 2.
Error while building/deploying project untitled (kit: Desktop Qt 5.2.0 MSVC2012 32bit)
When executing step 'Make'
13:58:18: Elapsed time: 00:04.
“问题重复”的解释:
我也看了文章Mismatch Detected for 'RuntimeLibrary'但不同的是,我的问题是关于在 Qt 中设置 NVCC,它比在 MSVC 环境中更复杂。即使/MDd 由以下代码设置,如果没有正确设置 NVCC,cu 文件仍然无法编译。运行时库的简单更改并不能完全解决我的问题。正是NVCC的设定最终成就了它。
# 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"
最佳答案
我通过阅读另一篇文章解决了我的问题 http://robot9.me/cuda_qtcreator_windows/
作为问题Mismatch Detected for 'RuntimeLibrary'建议。 MSVCRT 链接选项需要保持一致。所以在 NVCC 配置之前添加了 /MDd
设置。
但关键是要正确设置cuda.commands
。不同于问题:Compiling Cuda code in Qt Creator on Windows (我试过那个配置但对我不起作用)我的 nvcc 是这样设置的:
# 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"
CONFIG(debug, debug|release) {
#Debug settings
# Debug mode
cuda_d.input = CUDA_SOURCES
cuda_d.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}_cuda.obj
cuda_d.commands = $$CUDA_DIR/bin/nvcc.exe -D_DEBUG $$NVCC_OPTIONS $$CUDA_INC $$LIBS \
--machine $$SYSTEM_TYPE -arch=$$CUDA_ARCH \
--compile -cudart static -g -DWIN32 -D_MBCS \
-Xcompiler "/wd4819,/EHsc,/W3,/nologo,/Od,/Zi,/RTC1" \
-Xcompiler $$MSVCRT_LINK_FLAG_DEBUG \
-c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
cuda_d.dependency_type = TYPE_C
QMAKE_EXTRA_COMPILERS += cuda_d
}
else {
# Release settings
cuda.input = CUDA_SOURCES
cuda.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}_cuda.obj
cuda.commands = $$CUDA_DIR/bin/nvcc.exe $$NVCC_OPTIONS $$CUDA_INC $$LIBS \
--machine $$SYSTEM_TYPE -arch=$$CUDA_ARCH \
--compile -cudart static -DWIN32 -D_MBCS \
-Xcompiler "/wd4819,/EHsc,/W3,/nologo,/O2,/Zi" \
-Xcompiler $$MSVCRT_LINK_FLAG_RELEASE \
-c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
cuda.dependency_type = TYPE_C
QMAKE_EXTRA_COMPILERS += cuda
}
虽然我还没有完全理解一些cuda.commands,但它确实有效。请引用http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#axzz3FOBrgXpc有关 NVCC 配置的更多详细信息。
这是我的 .pro 文件的完整版本
#-------------------------------------------------
#
# Project created by QtCreator 2013-09-01T16:29:35
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = FFTW //your project name
TEMPLATE = app
HEADERS += dialog.h \
include/fftw3.h \ //header i need for my project
SOURCES += main.cpp\
dialog.cpp
INCLUDEPATH += $$PWD/
DEPENDPATH += $$PWD/
DESTDIR = debug
OBJECTS_DIR = debug/obj # directory where .obj files will be saved
CUDA_OBJECTS_DIR = debug/obj # directory where .obj of cuda file will be saved
# This makes the .cu files appear in your project
OTHER_FILES += intmapping.cu # this is my cu file need to compile
# CUDA settings <-- may change depending on your system
CUDA_SOURCES += intmapping.cu # let NVCC know which file you want to compile CUDA NVCC
CUDA_SDK = "C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C" # Path to cuda SDK install
CUDA_DIR = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v6.5"
SYSTEM_NAME = Win32 # Depending on your system either 'Win32', 'x64', or 'Win64'
SYSTEM_TYPE = 32 # '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 # default setting
# include paths
INCLUDEPATH += $$CUDA_DIR/include\
$$CUDA_SDK/common/inc\
$$CUDA_SDK/../shared/inc\
# library directories
QMAKE_LIBDIR += $$join(CUDA_DIR,'" -I"','-I"','"')/lib/$$SYSTEM_NAME\
$$join(CUDA_SDK,'" -I"','-I"','"')/common/lib/$$SYSTEM_NAME\
$$join(CUDA_SDK,'" -I"','-I"','"')/../shared/lib/$$SYSTEM_NAME
# Add the necessary libraries
CUDA_LIBS= -lcuda -lcudart -lcufft
#add quotation for those directories contain space (Windows required)
CUDA_INC +=$$join(INCLUDEPATH,'" -I"','-I"','"')
LIBS += $$CUDA_LIBS
#nvcc config
# 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"
CONFIG(debug, debug|release) {
#Debug settings
# Debug mode
cuda_d.input = CUDA_SOURCES
cuda_d.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}_cuda.obj
cuda_d.commands = $$CUDA_DIR/bin/nvcc.exe -D_DEBUG $$NVCC_OPTIONS $$CUDA_INC $$LIBS \
--machine $$SYSTEM_TYPE -arch=$$CUDA_ARCH \
--compile -cudart static -g -DWIN32 -D_MBCS \
-Xcompiler "/wd4819,/EHsc,/W3,/nologo,/Od,/Zi,/RTC1" \
-Xcompiler $$MSVCRT_LINK_FLAG_DEBUG \
-c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
cuda_d.dependency_type = TYPE_C
QMAKE_EXTRA_COMPILERS += cuda_d
}
else {
# Release settings
cuda.input = CUDA_SOURCES
cuda.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}_cuda.obj
cuda.commands = $$CUDA_DIR/bin/nvcc.exe $$NVCC_OPTIONS $$CUDA_INC $$LIBS \
--machine $$SYSTEM_TYPE -arch=$$CUDA_ARCH \
--compile -cudart static -DWIN32 -D_MBCS \
-Xcompiler "/wd4819,/EHsc,/W3,/nologo,/O2,/Zi" \
-Xcompiler $$MSVCRT_LINK_FLAG_RELEASE \
-c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
cuda.dependency_type = TYPE_C
QMAKE_EXTRA_COMPILERS += cuda
}
FORMS += \
dialog.ui
win32: LIBS += -L$$PWD/lib/ -llibfftw3f-3 #library i need in my project
INCLUDEPATH += $$PWD/lib
DEPENDPATH += $$PWD/lib
关于c++ - 编译cuda文件报错: "runtime library" mismatch value 'MDd_DynamicDebug' doesn't match value 'MTd_StaticDebug' in vectorAddition_cuda. o,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26205608/
我正在尝试将我的 xcode 应用程序存档到 Itunes,但我得到了 following errors : 1.) “配置文件不支持推送通知。” 2.) “配置文件不包含 aps-environme
我正在尝试为我们的组织构建一个 Web 应用程序,它将使用我们的 O365 进行身份验证。在尝试使用管理员帐户连接到域时,我遇到了这个错误,其中提到 admin..onmicrosoft.com(全局
当我尝试构建 MUAI 项目时,它给出错误“该项目不知道如何运行配置文件 sample.WinUI”。项目已构建但无法运行。我使用的是 Visual Studio 2022 Preview(17.0
当某项包含在列表中时,有一个查询要搜索,但当某项不在列表中时,则没有查询。 此查询查找在给定列表 cdiffnums 中没有 ContactNum 的 customer 对象。我该怎么做才能仅返回此列
我们有一个黑盒第三方 Java 程序,可以从某个位置获取输入文件并制作 PDF。每次输入时,它都会将 list 文件放在同一位置,这需要我们以受控方式提供文件。 list (或 .xen/.que)是
我看到这个has选择器,hasnt 选择器在哪里?我想查找不包含图像的表格。 最佳答案 类似$("table:not(:has(img))")? 关于jQuery: "Doesn' t 有“选择器?,
为什么?这让我发疯??? $(document).ready(function () { $('#slides1').bxSlider({ prev_
我是 kubernetes 的新手。 我无法使用 kubectl 进行部署,但我可以在 kubernetes 仪表板上看到所有部署。我该如何解决这个问题? user@master:~$ kubectl
这个问题已经有答案了: What do querySelectorAll and getElementsBy* methods return? (12 个回答) 已关闭 6 年前。 HTML JS
我有两个数组,一个包含字符串值,另一个包含整数值,尽管这可能很愚蠢,但我陷入了困境,我需要一点帮助,我想遍历两者,如果 arr1 包含 arr2 中不存在的项目,它将被推送到 newArray 这是我
我一直在尝试为我的网站安装一个 PHP 脚本,设置所有内容,通过脚本附带的 phpMyAdmin 导入 SQL 文件,但我面对的是一个空白页面,错误如下所示: File /home/user/publ
我正在努力将站点的服务器从 PHP 5.2.17 升级到 5.5,以使其在未来的升级中保持新鲜,并安装其他需要 PHP 5.4+ 的软件。 数据库有一个我正在测试的表,其中有许多列在初始 INSERT
我一直收到这个错误: Object doesn't support this property or method 每当我在 IE7 和 IE8 中运行我的代码时。这是它停止的代码: _renderU
我想使用正则表达式排除某些单词。 输入文本: aaa1234 cc bbb1234 c1234 cc dd aacc cccc ccadf cc 输出文本: aaa1234 bbb1234 c1234
我有一个名为 adjust_status 的存储函数和一个包含 status 列的表 users。 select adjust_status(status) as adjusted_status
我有一个表,其中有一列由插入前触发器填充,该列设置为 NOT NULL 并且没有DEFAULT VALUE。 当我执行 INSERT TABLE 而不传递此列时,我收到错误:1364 - Field
这个问题已经有答案了: Modify the value of each textfield based on original value using jQuery (3 个回答) 已关闭去年。 使
我正在阅读 this , 它说 @keyframes rules don't cascade, so animations never derive keyframes from more than
编辑:我解决了问题,请参阅答案中的链接。 我正在使用 XMLHttpRequest AJAX API 将来自不同网站的数据发送到我们在 PythonAnywhere 中的服务器。奇怪的事情发生了:根据
我已经阅读了 Linux 调用 dlopen() 和 dlsym() 的文档,它们分别打开一个动态库并在库中加载一个符号。 这些调用似乎等同于 Windows 的 LoadLibrary() 和 Ge
我是一名优秀的程序员,十分优秀!