检测到'RuntimeLibrary'不匹配:值'MD_DynamicRelease'与值'MT_StaticRelease'不匹配 [英] mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease'

查看:379
本文介绍了检测到'RuntimeLibrary'不匹配:值'MD_DynamicRelease'与值'MT_StaticRelease'不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello

我尝试使用Qtcreator和Cuda库在Windows上编译项目。编译在一个简单的cuda文件和cpp文件上正常工作但是当我尝试添加多个cuda文件时,我得到了这个错误:

I try to compile a project on Windows with Qtcreator and Cuda library. The compilation works fine on a simple cuda file and cpp files but when I try to add more than one cuda file I get that error:

mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease'

这是我的.pro文件:

Here is my .pro file:

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = untitled
TEMPLATE = app


#HEADERS  += mainwindow.h
#FORMS    += mainwindow.ui


# Define output directories
DESTDIR = release
OBJECTS_DIR = release/obj
CUDA_OBJECTS_DIR = release/obj

# Source files

# This makes the .cu files appear in your project
SOURCES += \
    src/main.cpp #\



# CUDA settings <-- may change depending on your system
CUDA_SOURCES += ./cuda/Blending.cu
CUDA_SOURCES += ./cuda/CCL.cu



INCLUDEPATH += C:\opencv\build\include
INCLUDEPATH += C:\opencv\build\include\opencv

#LIBS+= -LC:\\opencv\\build\\x86\\vc12\\lib
#LIBS+=libopencv_core24134
#LIBS+=libopencv_imgproc2413
#LIBS+=libopencv_highgui2413
#LIBS+=libopencv_objdetect2413
#LIBS+=libopencv_calib3d2413

LIBS+=C:\opencv\build\x86\vc12\lib\opencv_core2413.lib
LIBS+=C:\opencv\build\x86\vc12\lib\opencv_imgproc2413.lib
LIBS+=C:\opencv\build\x86\vc12\lib\opencv_highgui2413.lib
LIBS+=C:\opencv\build\x86\vc12\lib\opencv_objdetect2413.lib
LIBS+=C:\opencv\build\x86\vc12\lib\opencv_calib3d2413.lib

LIBSCUDA += -LC:\opencv\build\x86\vc12\lib
LIBSCUDA += -lopencv_core2413
LIBSCUDA += -lopencv_imgproc2413
LIBSCUDA += -lopencv_highgui2413
LIBSCUDA += -lopencv_objdetect2413
LIBSCUDA += -lopencv_calib3d2413


CUDA_SDK = "C:/ProgramData/NVIDIA Corporation/CUDA Samples/v8.0"#"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\v8.0"            # 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 = compute_50           # 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 = "/FS"

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



     cuda.input    = CUDA_SOURCES
     cuda.output   = ${QMAKE_FILE_BASE}_cuda.o
     cuda.commands = $$CUDA_DIR/bin/nvcc.exe -dlink $$NVCC_OPTIONS $$CUDA_INC $$LIBSCUDA \
                    --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


HEADERS += \

    cuda/Blending.h# \

当我编译一个简单的cuda文件时,MSVCRT_LINK_FLAG_RELEASE是/ MD但编译器建议我将它设置为/ FS以获取多个文件:

When I compile a simple cuda file MSVCRT_LINK_FLAG_RELEASE was /MD but th compiler advive me to set it at /FS for mutiple file:

MSVCRT_LINK_FLAG_RELEASE = "/FS"

但现在我收到这些错误:

But now I get these errors:

../CudaWindows/cuda/CCL.cu(478): warning C4244: 'argument': conversion from 'float' to 'unsigned int', possible loss of data
../CudaWindows/cuda/CCL.cu(594): warning C4244: 'argument': conversion from 'float' to 'unsigned int', possible loss of data
	link /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:release\untitled.exe @C:\Users\SENIOR~1\AppData\Local\Temp\untitled.exe.5992.5266.jom
main.obj : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in Blending_cuda.o
msvcprt.lib(MSVCP140.dll) : error LNK2005: "bool __cdecl std::uncaught_exception(void)" (?uncaught_exception@std@@YA_NXZ) already defined in libcpmt.lib(uncaught.obj)
msvcprt.lib(MSVCP140.dll) : error LNK2005: "void __cdecl std::_Xbad_alloc(void)" (?_Xbad_alloc@std@@YAXXZ) already defined in libcpmt.lib(xthrow.obj)
msvcprt.lib(MSVCP140.dll) : error LNK2005: "void __cdecl std::_Xlength_error(char const *)" (?_Xlength_error@std@@YAXPBD@Z) already defined in libcpmt.lib(xthrow.obj)
msvcprt.lib(MSVCP140.dll) : error LNK2005: "void __cdecl std::_Xout_of_range(char const *)" (?_Xout_of_range@std@@YAXPBD@Z) already defined in libcpmt.lib(xthrow.obj)
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputc(char)" (?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z) already defined in Blending_cuda.o
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: __int64 __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,__int64)" (?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE_JPBD_J@Z) already defined in Blending_cuda.o
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::setstate(int,bool)" (?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z) already defined in Blending_cuda.o
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: void __thiscall std::basic_ostream<char,struct std::char_traits<char> >::_Osfx(void)" (?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in Blending_cuda.o
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(bool)" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_N@Z) already defined in Blending_cuda.o
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(int)" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z) already defined in Blending_cuda.o
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(unsigned int)" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@I@Z) already defined in Blending_cuda.o
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(float)" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z) already defined in Blending_cuda.o
msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::flush(void)" (?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ) already defined in Blending_cuda.o
qtmain.lib(qtmain_win.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in Blending_cuda.o
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
main.obj : warning LNK4217: locally defined symbol __invalid_parameter_noinfo_noreturn imported in function "void __cdecl std::_Deallocate(void *,unsigned int,unsigned int)" (?_Deallocate@std@@YAXPAXII@Z)
main.obj : warning LNK4217: locally defined symbol _memmove imported in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::erase(unsigned int,unsigned int)" (?erase@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@II@Z)
Blending_cuda.o : error LNK2019: unresolved external symbol ___cudaRegisterLinkedBinary_44_tmpxft_0000148c_00000000_11_Blending_cpp1_ii_38dfa19b referenced in function "void __cdecl __sti____cudaRegisterAll_44_tmpxft_0000148c_00000000_11_Blending_cpp1_ii_38dfa19b(void)" (?__sti____cudaRegisterAll_44_tmpxft_0000148c_00000000_11_Blending_cpp1_ii_38dfa19b@@YAXXZ)
CCL_cuda.o : error LNK2019: unresolved external symbol ___cudaRegisterLinkedBinary_39_tmpxft_00002268_00000000_11_CCL_cpp1_ii_6461764f referenced in function "void __cdecl __sti____cudaRegisterAll_39_tmpxft_00002268_00000000_11_CCL_cpp1_ii_6461764f(void)" (?__sti____cudaRegisterAll_39_tmpxft_00002268_00000000_11_CCL_cpp1_ii_6461764f@@YAXXZ)
MSVCRT.lib(_chandler4gs_.obj) : error LNK2019: unresolved external symbol __except_handler4_common referenced in function __except_handler4
release\untitled.exe : fatal error LNK1120: 3 unresolved externals







推荐答案

您好bird12358,

Hi bird12358,

感谢您的发布这里。

>>'RuntimeLibrary'检测到不匹配:值'MD_DynamicRelease'与值'MT_StaticRelease'不匹配

此错误是因为您的项目与您的库具有不同的C运行时库设置。传递给链接器的给定调用的所有模块必须使用相同的运行时库编译器选项进行编译(/ MD ,/ MT,/ LD)。

This error is because your project has different settings of the C Runtime Library with your libraries.All modules passed to a given invocation of the linker must have been compiled with the same run-time library compiler option (/MD, /MT, /LD).

有关详细信息,请参阅以下文档。

For more information, please refer to this document below.

https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx

此论坛是关于使用Microsoft产品进行c ++开发的。对于您的情况,我建议您前往
QT论坛以获得更好的支持。

And this forum is about c++ development with Microsoft products. For your case, I suggest you go to QT forum for better support.

您的理解与合作将不胜感激。

Your understanding and cooperation will be grateful.

最诚挚的问候,以
Sera Yu

Best Regards,
Sera Yu


这篇关于检测到'RuntimeLibrary'不匹配:值'MD_DynamicRelease'与值'MT_StaticRelease'不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆