我正在尝试在我的项目中解决此常见链接器警告,该项目使用Qt和Assimp加载3D模型。我正在使用VS2008并且已经使用VS2008编译了Qt5.1和Assimp。我使用了Boost的预编译版本(从boost_1_55_0-msvc-9.0-32.exe安装)我将Assimp设置为发布版本win32。 C ++代码生成设置为多线程DLL(/ MD)并在我的项目中使用assimp.lib,它设置为多线程调试DLL(/ MDd)。我不确定哪个库导致冲突。如果我注释掉加载模型的cpp文件中的代码,警告就会消失。
我的库依赖项是:
qtmaind.lib Qt5Cored.lib Qt5Guid.lib Qt5Networkd.lib
Qt5Widgetsd.lib Qt5OpenGLd.lib opengl32.lib glu32.lib assimp.lib
http://msdn.microsoft.com/en-us/library/abx4dbyh.aspx
Resolving LNK4098: defaultlib 'MSVCRT' conflicts with
Creating library c:\Visual Studio 2008\Projects\qtdisplay\Win32\Debug\QuadPlanner.lib and object c:\Visual Studio 2008\Projects\qtdisplay\Win32\Debug\QuadPlanner.exp
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>Linking...
1>Searching libraries
1> Searching C:\Qt\Qt5.1.1\lib\qtmaind.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5Cored.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5Guid.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5Networkd.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5Widgetsd.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5OpenGLd.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\opengl32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\glu32.lib:
1> Searching c:\Visual Studio 2008\Projects\qtdisplay\qtdisplay\\..\lib\assimp.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\msvcprtd.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\MSVCRTD.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\msvcprt.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\MSVCRT.lib:
1> Searching C:\Qt\Qt5.1.1\lib\qtmaind.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5Cored.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5Guid.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5Networkd.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5Widgetsd.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5OpenGLd.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\opengl32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\glu32.lib:
1> Searching c:\Visual Studio 2008\Projects\qtdisplay\qtdisplay\\..\lib\assimp.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\msvcprtd.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\MSVCRTD.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\msvcprt.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\MSVCRT.lib:
1>Finished searching libraries
1> Creating library C:\Visual Studio 2008\Projects\qtdisplay\Win32\Debug\qtdisplay.lib and object C:\Visual Studio 2008\Projects\qtdisplay\Win32\Debug\qtdisplay.exp
1>Searching libraries
1> Searching C:\Qt\Qt5.1.1\lib\qtmaind.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5Cored.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5Guid.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5Networkd.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5Widgetsd.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5OpenGLd.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\opengl32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\glu32.lib:
1> Searching c:\Visual Studio 2008\Projects\qtdisplay\qtdisplay\\..\lib\assimp.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\msvcprtd.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\MSVCRTD.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\msvcprt.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\MSVCRT.lib:
1>Finished searching libraries
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>Searching libraries
1> Searching C:\Qt\Qt5.1.1\lib\qtmaind.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5Cored.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5Guid.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5Networkd.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5Widgetsd.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5OpenGLd.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\opengl32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\glu32.lib:
1> Searching c:\Visual Studio 2008\Projects\qtdisplay\qtdisplay\\..\lib\assimp.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\msvcprtd.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\MSVCRTD.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\msvcprt.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\MSVCRT.lib:
1> Searching C:\Qt\Qt5.1.1\lib\qtmaind.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5Cored.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5Guid.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5Networkd.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5Widgetsd.lib:
1> Searching C:\Qt\Qt5.1.1\lib\Qt5OpenGLd.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\opengl32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\glu32.lib:
1> Searching c:\Visual Studio 2008\Projects\qtdisplay\qtdisplay\\..\lib\assimp.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\msvcprtd.lib:
1>Finished searching libraries
1>Embedding manifest...
1>Build log was saved at "file://C:\Visual Studio 2008\Projects\qtdisplay\Win32\Debug\BuildLog.htm"
1>qtdisplay - 0 error(s), 1 warning(s)
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
编辑: 我刚刚使用debug-noboost-st构建配置(/ MDd)构建了Assimp,它解决了警告(谢谢,Laszlo)。我没有意识到调试和发布库应该只与它们各自的构建配置一起使用而不是混合。
Mixing debug and release library/binary - bad practice?
为了将来参考,我发现这些主题很有帮助:
从源头构建提升: Boost compiling with MSVC 11 (VS 2012) Trying to build Boost: I cannot get bjam
bjam toolset = msvc-9.0 variant = release,debug link = static,shared threading = multi install
一位同事提到,如果您将Visual Studio Service Pack之前的库与修补后的visual studio混合,也会导致此特定错误。
答案 0 :(得分:1)
尝试调整cxx标志。
QMAKE_CXXFLAGS += -Md # or you could use /Md
http://msdn.microsoft.com/en-us/library/aa278396(v=vs.60).aspx
如果查看编译器输出,可以看到它将/ Md放入mt.exe
或cl.exe
命令的使用时间。
希望有所帮助。
答案 1 :(得分:0)
您似乎正在混合库的发布和调试版本。
qtmaind.lib Qt5Cored.lib Qt5Guid.lib Qt5Networkd.lib Qt5Widgetsd.lib Qt5OpenGLd.lib
这些似乎是在调试模式下构建的,因为您可以在扩展前的主库名称之后从'd'市场看到。
opengl32.lib glu32.lib assimp.lib
这些没有'd',所以你可以看到这些都是在发布模式下构建的。这通常在Windows项目中不起作用。你应该确保你有相同类型的构建。
现在您已经在发布模式中构建了低级opengl,glu和assimp库,我建议您以与应用程序相同的方式构建Qt。
您可以使用release
变量的CONFIG
选项在following way中实现该目标:
release项目将以发布模式构建。如果还指定了debug,则忽略此项。
您也可以通过将以下行放入qmake项目文件来获取本机Windows。但是,最好使用qmake CONFIG
变量,因为这是一个跨平台的解决方案。
QMAKE_CXXFLAGS + = -MD