错误 LNK2038:检测到“_ITERATOR_DEBUG_LEVEL”不匹配:值“0”与值“2”不匹配在 main.obj 中
我已经阅读了很多针对我的问题的解决方案,但没有一个有帮助。我尝试清理、重建。重新安装了visual 2010,从专业改为旗舰。但我仍然不知道为什么会出现这个错误。 我的项目看起来像这样: 1 Exe 解决方案来测试我的静态库。 1 个 Dll 解决方案静态库。 转换为 dll 的代码使用 1 个名为 ClassificationFramework 的库中的函数。我提供了这个库作为标头和 cpp,所以基本上是源代码。在 Exe 解决方案中,我链接了生成的库 + 一些其他库来运行它 + ClassificationFramework.dll。当我使用 Release 时,一切工作正常,但是当我更改为 Debug 时(因为我想调试一些东西,我厌倦了在发布模式下跳过调试器),我得到这个:
2>Link:
2> ClassificationFramework.lib(SampleClass.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
2>ClassificationFramework.lib(SampleClass.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
2>ClassificationFramework.lib(SampleNamesSet.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
2>ClassificationFramework.lib(SampleSet.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
2>ClassificationFramework.lib(DirectoryReader.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
2>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
2>C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Transformer\Debug\Tester.exe : fatal error LNK1319: 4 mismatches detected
当我在 Release 中构建时,我也收到这些警告:
1>Link:
1> Generating code
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(101): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because ptimizations are disabled in function
1>c:\users\kasia\documents\visual studio 2010\projects\classificationframework\classificationframework\directoryreader.cpp(30): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\xstring(1589): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
1>c:\users\kasia\documents\visual studio 2010\projects\classificationframework\classificationframework\samplenamesset.cpp(226): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
1>c:\users\kasia\documents\visual studio 2010\projects\classificationframework\classificationframework\directoryreader.cpp(60): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
1>c:\users\kasia\documents\visual studio 2010\projects\classificationframework\classificationframework\samplenamesset.cpp(199): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
1>c:\users\kasia\documents\visual studio 2010\projects\classificationframework\classificationframework\sampleset.cpp(27): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
1>c:\users\kasia\documents\visual studio 2010\projects\classificationframework\classificationframework\samplenamesset.cpp(59): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
1> Finished generating code
1>ClassificationFramework.lib(SampleSet.obj) : warning LNK4099: PDB 'vc100.pdb' was not found with 'ClassificationFramework.lib(SampleSet.obj)' or at 'C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Transformer\Release\vc100.pdb'; linking object as if no debug info
1>ClassificationFramework.lib(SampleNamesSet.obj) : warning LNK4099: PDB 'vc100.pdb' was not found with 'ClassificationFramework.lib(SampleNamesSet.obj)' or at 'C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Transformer\Release\vc100.pdb'; linking object as if no debug info
1>ClassificationFramework.lib(SampleClass.obj) : warning LNK4099: PDB 'vc100.pdb' was not found with 'ClassificationFramework.lib(SampleClass.obj)' or at 'C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Transformer\Release\vc100.pdb'; linking object as if no debug info
1>ClassificationFramework.lib(DirectoryReader.obj) : warning LNK4099: PDB 'vc100.pdb' was not found with 'ClassificationFramework.lib(DirectoryReader.obj)' or at 'C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Transformer\Release\vc100.pdb'; linking object as if no debug info
1> Tester.vcxproj -> C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Transformer\Release\Tester.exe
我发现由于 pdb 文件的路径错误,调试器会跳过。
'Tester.exe': Loaded 'C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Work\Release\Tester.exe', Symbols loaded.
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'Tester.exe': Unloaded 'C:\WINDOWS\SysWOW64\kernel32.dll'
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\OpenCV2.2\bin\opencv_core220.dll', Binary was not built with debug information.
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\msvcp100.dll', Symbols loaded.
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\msvcr100.dll', Symbols loaded.
'Tester.exe': Loaded 'C:\OpenCV2.2\bin\opencv_highgui220.dll', Binary was not built with debug information.
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\user32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\gdi32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\advapi32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\secur32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\ole32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\msvcrt.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_5.82.3790.4770_x-ww_A689AB02\comctl32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\avifil32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\winmm.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\msacm32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\msvfw32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\shell32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\shlwapi.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\avicap32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\version.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\OpenCV2.2\bin\opencv_imgproc220.dll', Binary was not built with debug information.
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\imm32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\lpk.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\usp10.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\WinSxS\wow64_Microsoft.Windows.Common- Controls_6595b64144ccf1df_6.0.3790.4770_x-ww_8D2E3180\comctl32.dll', Cannot find or open the PDB file
The program '[4984] Tester.exe: Native' has exited with code 0 (0x0).
当我转到“调试”->“Windows”->“模块”时,我发现他找不到那些 pdb 文件或其他文件。我怎么能告诉他这些文件在这里和这里呢?我尝试以管理员身份运行 MSvisual,但这也没有帮助。我使用微软服务器加载 pdb 文件,但也没有帮助。
I have read a lot of solutions to my problem but none helped. I tried clean, rebuild. Reinstalled visual 2010 and change from professional to ultimate. But still I dont know why I have this error.
My project look like this:
1 Exe Solution to test my static library.
1 Dll Solution static library.
Code which is converted to dll is using function from 1 lib called ClassificationFramework. I provided this lib as headers and cpp so basically source code. In Exe solution I linked my generated library + some other libs to run it + ClassificationFramework.dll. Everything works fine when I use Release but when I change to Debug (because I want to debug some stuff, I am tired of skipping debugger in release mode) I get this:
2>Link:
2> ClassificationFramework.lib(SampleClass.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
2>ClassificationFramework.lib(SampleClass.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
2>ClassificationFramework.lib(SampleNamesSet.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
2>ClassificationFramework.lib(SampleSet.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
2>ClassificationFramework.lib(DirectoryReader.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
2>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
2>C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Transformer\Debug\Tester.exe : fatal error LNK1319: 4 mismatches detected
When I build in Release I also got these warnings:
1>Link:
1> Generating code
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(101): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because ptimizations are disabled in function
1>c:\users\kasia\documents\visual studio 2010\projects\classificationframework\classificationframework\directoryreader.cpp(30): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\xstring(1589): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
1>c:\users\kasia\documents\visual studio 2010\projects\classificationframework\classificationframework\samplenamesset.cpp(226): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
1>c:\users\kasia\documents\visual studio 2010\projects\classificationframework\classificationframework\directoryreader.cpp(60): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
1>c:\users\kasia\documents\visual studio 2010\projects\classificationframework\classificationframework\samplenamesset.cpp(199): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
1>c:\users\kasia\documents\visual studio 2010\projects\classificationframework\classificationframework\sampleset.cpp(27): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
1>c:\users\kasia\documents\visual studio 2010\projects\classificationframework\classificationframework\samplenamesset.cpp(59): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
1> Finished generating code
1>ClassificationFramework.lib(SampleSet.obj) : warning LNK4099: PDB 'vc100.pdb' was not found with 'ClassificationFramework.lib(SampleSet.obj)' or at 'C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Transformer\Release\vc100.pdb'; linking object as if no debug info
1>ClassificationFramework.lib(SampleNamesSet.obj) : warning LNK4099: PDB 'vc100.pdb' was not found with 'ClassificationFramework.lib(SampleNamesSet.obj)' or at 'C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Transformer\Release\vc100.pdb'; linking object as if no debug info
1>ClassificationFramework.lib(SampleClass.obj) : warning LNK4099: PDB 'vc100.pdb' was not found with 'ClassificationFramework.lib(SampleClass.obj)' or at 'C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Transformer\Release\vc100.pdb'; linking object as if no debug info
1>ClassificationFramework.lib(DirectoryReader.obj) : warning LNK4099: PDB 'vc100.pdb' was not found with 'ClassificationFramework.lib(DirectoryReader.obj)' or at 'C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Transformer\Release\vc100.pdb'; linking object as if no debug info
1> Tester.vcxproj -> C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Transformer\Release\Tester.exe
I found that Debugger skips because of wrong path to pdb files.
'Tester.exe': Loaded 'C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Work\Release\Tester.exe', Symbols loaded.
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'Tester.exe': Unloaded 'C:\WINDOWS\SysWOW64\kernel32.dll'
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\OpenCV2.2\bin\opencv_core220.dll', Binary was not built with debug information.
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\msvcp100.dll', Symbols loaded.
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\msvcr100.dll', Symbols loaded.
'Tester.exe': Loaded 'C:\OpenCV2.2\bin\opencv_highgui220.dll', Binary was not built with debug information.
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\user32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\gdi32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\advapi32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\secur32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\ole32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\msvcrt.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_5.82.3790.4770_x-ww_A689AB02\comctl32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\avifil32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\winmm.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\msacm32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\msvfw32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\shell32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\shlwapi.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\avicap32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\version.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\OpenCV2.2\bin\opencv_imgproc220.dll', Binary was not built with debug information.
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\imm32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\lpk.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\usp10.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\WinSxS\wow64_Microsoft.Windows.Common- Controls_6595b64144ccf1df_6.0.3790.4770_x-ww_8D2E3180\comctl32.dll', Cannot find or open the PDB file
The program '[4984] Tester.exe: Native' has exited with code 0 (0x0).
When i go to Debug->Windows->Modules i see that he cannot find those pdb files or something. How i can say him that those files are here here and here? I tried to run MSvisual as administrator but that too didnt help. I used microsoft server to load pdb files but also didnt help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(25)
在 VS2010 中,迭代器调试级别在调试中默认为 2,在发布中被禁用。您正在使用的 dll 之一可能在调试中关闭了迭代器调试,因为它是在旧版本的 Visual Studio 中构建的,或者它们显式地将定义添加到了项目中。
搜索
_ITERATOR_DEBUG_LEVEL
和_SECURE_SCL
将其删除或在所有项目和源中适当设置它们并重建所有内容。简而言之,您可能正在混合发布和调试 dll。不要在调试中链接发布 dll,反之亦然!
In VS2010 iterator debug level defaults to 2 in debug and is disabled in release. One of the dlls you are using probably has iterator debugging turned off in debug either because it was built in an older version of visual studio or they explicitly added the defines to the project.
Search for
_ITERATOR_DEBUG_LEVEL
and_SECURE_SCL
remove them or set them appropriately in all projects and sources and rebuild everything.In short you are probably mixing release and debug dlls. Don't linked release dlls in debug or vice versa!
我对此问题做了一些更新,因为在我将旧的 Visual 6 项目迁移到 Visual Studio 2012 后,今天在链接静态库的应用程序上遇到了相同的错误。
在我的情况下,错误是我错误地使用/MDd而不是/MD编译静态库的Release版本,而应用程序在release中是/MD。在静态库项目中设置正确的 /MD 解决了该问题。
这是在项目属性中完成的,
I make a little update on this issue, as I just had the same error today on an application which is linking against a static lib, after I migrated the old Visual 6 project to Visual Studio 2012.
In my case the error was that I mistakenly compiled the Release version of the static lib with /MDd instead of /MD, whereas the application is /MD in release. Setting the correct /MD in the static lib project solved the issue.
This is done in Project properties
如果您想故意将发布中的项目 A 与调试中的另一个项目 B 链接起来,比如在调试时保持应用程序的整体性能优势,那么您可能会遇到此错误。您可以通过临时修改项目 B 的预处理器标志以禁用迭代器调试(并使其与项目 A 匹配)来解决此问题:
在项目 B 的“调试”属性中,配置属性 -> C/C++->预处理器,将以下内容添加到预处理器定义中:
在调试中重新构建项目 B,然后在发布中构建项目 A,它应该正确链接。
If you would like to purposely link your project A in Release against another project B in Debug, say to keep the overall performance benefits of your application while debugging, then you will likely hit this error. You can fix this by temporarily modifying the preprocessor flags of project B to disable iterator debugging (and make it match project A):
In Project B's "Debug" properties, Configuration Properties -> C/C++ -> Preprocessor, add the following to Preprocessor Definitions:
Rebuild project B in Debug, then build project A in Release and it should link correctly.
最后机会(如果其他方法不起作用):
在所有项目中定义 _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH 宏。它将禁用 CRT 标头中使用的“#pragma detector_mismatch”功能。
Last chance (if other ways don't work):
define _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH macro in all projects. It will disable "#pragma detect_mismatch" feature which is used in CRT headers.
该错误可能是由于在同一可执行文件或 dll 中混合调试版本和发布版本而引起的。
The error can be caused by mixing together debug builds and release builds in same executable or dll.
我的项目之间不匹配:一个使用多字节字符集,另一个使用 Unicode。更正这些内容以就 Unicode 达成一致解决了该问题。
I had a mismatch between projects: one with multi-byte character set, the other with Unicode. Correcting these to agree on Unicode corrected the problem.
我也有这个问题。
我的问题是我已经从调试配置中复制/粘贴了库包含目录。
因此,项目“Indep”包括来自“../Debug”的静态库“Dep.lib”,即使在发布版本中也是如此。修复方法是将库目录更改为“../Release”,这样我就捕获了发布版本构建的库,而不是之前构建的调试库。
I had this problem as well.
My problem was that I had copy/pasted the library include directories from my debug configurations.
So project "Indep" was including static library "Dep.lib" from "../Debug", even in release. The fix was to change the library directory to "../Release" so I caught the release-built library rather than the previously-built debug library.
我在调试和发布库之间遇到了同样的问题。
错误出现在解决方案属性/配置属性/配置中。
项目配置与主要配置/平台不匹配。
I had the same issue between debug and release libraries.
The mistake was in the solution properties / Configurations properties / Configurations.
The projects configurations did not match the main configuration / platform.
尝试在 C++ 项目属性中将 _DEBUG 更改为 NDEBUG 宏定义(用于发布配置)
配置属性-> C/C++->预处理器->预处理器定义
Try change _DEBUG to NDEBUG macro definition in C++ project properties (for Release configuration)
Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions
opencv_core245.lib(dxt.obj):错误 LNK2038:检测到“_ITERATOR_DEBUG_LEVEL”不匹配:值“0”与 test.obj 中的值“2”不匹配我收到这样的错误。
我在链接器->输入->附加依赖项中有opencv_core245.lib和opencv_core245d.lib。由于这两个是冲突的,我删除了第一个 opencv_core245.lib。错误消失了。
opencv_core245.lib(dxt.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in test.obj I got error like this.
I have opencv_core245.lib and opencv_core245d.lib in Linker->Input->Additional dependenc. Since this two were confilicting I removed first one opencv_core245.lib. Error gone.
试试这个:
转到项目属性-> C/C++->代码生成->运行时库
从组合框值中选择:多线程 DLL (/MD)
它对我有用:)
Try this:
Goto project property -> C/C++ -> Code generation -> Runtime Library
Select from combobox value : Multi-threaded DLL (/MD)
It work for me :)
对上述帮助的小补充:
使用 VST 2017 将静态库添加到旧的 VST 解决方案后,出现不匹配错误。
VST 现在为包含以下两行的预编译标头生成“stdfax.h”:
Small addition to the help above:
I got the mismatch error after adding a static libto an older VST solution using VST 2017 .
VST now generates "stdfax.h" for precompiled headers containing these 2 lines:
就我而言,对于调试和发布,解决方案是清理然后重建整个解决方案。
编辑:我的情况也是如此(VS2017)
步骤1:清理项目。
步骤2:更改配置模式(从调试到发布,反之亦然)。
第三步:清理项目。
step4:按照需要的配置模式进行构建。
PS:要更改配置模式,请在构建菜单下找到配置设置
In my case, for both Debug and Release, the solution was to clean then rebuild entire solution.
Edit: true in my case also (VS2017)
step1: clean the project.
step2: change configuration mode(from debug to release or vice versa).
step3: clean the project.
step4: build in the required configuration mode.
PS: to change config mode, find config settings under build menu
我今天遇到了同样的问题(VS2010),我构建了Release | Win32,然后尝试构建 Debug | Win32,并收到此消息。
我尝试清理调试 | Win32但错误仍然存在。
然后我清理了 Release | Win32,然后清理Debug | Win32,然后就构建得很好了。
I had the same problem today (VS2010), I built Release | Win32, then tried to build Debug | Win32, and got this message.
I tried cleaning Debug | Win32 but the error still persisted.
I then cleaned Release | Win32, then cleaned Debug | Win32, and then it built fine.
我设法通过将依赖库更改为“项目属性 ->”中的调试版本来摆脱此错误(在我的情况下使用 Ogre3D + Bullet)。链接器->输入->附加依赖项 (VC10)。
我将 BulletCollision.lib 更改为 BulletCollision_debug.lib (用于调试配置)并进行编译。
I managed to get rid of this error (in my case using Ogre3D + Bullet) by changing the dependency libraries to the debug versions in Project Properties -> Linker -> Input -> Additional Dependencies (VC10).
I changed BulletCollision.lib to BulletCollision_debug.lib (for debug configuration) and it compiled.
我解决了纠正“附加库目录”时遇到的麻烦,这个指示“$(SolutionDir)\Release”是错误的,我在“$(SolutionDir)\$(IntDir)”中更改了它
要纠正它,请打开您的项目属性->配置属性->链接器->一般->附加图书馆目录
我希望这能帮助一些有同样问题的人;)
I resolved my trouble in correcting the "Additional Library Directory", this one was wrong in indicating "$(SolutionDir)\Release", I changed it in "$(SolutionDir)\$(IntDir)"
To correct it, open your project properties -> Configuration Properties -> Linker -> General -> Additional Library Directory
I hope this will help some poeples with the same trouble ;)
如果现有答案都不适用,例如您正在使用 ASan,并与不适用的预构建库混合,那么您可能需要从编译器命令行中删除
-fsanitize=address
,作为解决方法。(参见例如 此在 MS Learn 上发布。)
If none of the existing answers apply, e.g. you're using ASan, mixed with prebuilt libs that don't, then you may need to remove
-fsanitize=address
from your compiler command-line, as a workaround.(See e.g. this post at MS Learn.)
我也遇到了这个问题,它的出现是因为我重新制作了该项目,然后忘记在依赖项目中通过引用重新链接它。
因此,它是通过引用旧项目而不是新项目来链接的。
重要的是要知道通过引用重新添加以前链接的项目时存在错误。您必须手动删除 vcxproj 中的引用,然后才能重新添加它。根据 msdn,这是 Visual Studio 中的一个已知问题。
I also had this issue and it arose because I re-made the project and then forgot to re-link it by reference in a dependent project.
Thus it was linking by reference to the old project instead of the new one.
It is important to know that there is a bug in re-adding a previously linked project by reference. You've got to manually delete the reference in the vcxproj and only then can you re-add it. This is a known issue in Visual studio according to msdn.
我遇到了类似的问题,但错误的设置位于我没有来源的 extern .lib 文件中。如果您没有源文件,最简单的解决方法是更改 .lib 文件的内容。
在编辑器中打开 .lib 文件(我使用 PSPad,也可以使用 Windows 记事本)并将所有出现的 _ITERATOR_DEBUG_LEVEL=2 替换为 _ITERATOR_DEBUG_LEVEL=0
I had similar problem, but the wrong setting was in the extern .lib file from which I did not have sources. If you do not have the source files, the simplest workaround is to just change the content of the .lib file.
Open the .lib file in an editor (I used PSPad, bud Windows notepad is also possible) and replace all occurences of _ITERATOR_DEBUG_LEVEL=2 to _ITERATOR_DEBUG_LEVEL=0
就我而言,“预处理器定义”中的 NDEBUG 宏定义需要更改为 _DEBUG。我正在构建一个用于 .exe 的静态库,该库抱怨问题中列出的完全相同的错误。转到配置属性(“项目”菜单,“属性”菜单项),然后单击 C/C++ 部分,然后单击其下的预处理器部分,然后编辑预处理器定义,以便将 NDEBUG 更改为 _DEBUG(以匹配exe 中的设置)。
In my case the NDEBUG macro definition in the "Preprocessor Definitions" needed to be changed to _DEBUG. I am building a static library for use in a .exe which was complaining about the very same error listed in the question. Go to Configuration Properties ("Project" menu, "Properties" menu item) and then click the C/C++, section, then the Preprocessor section under that, and then edit your Preprocessor Definitions so that NDEBUG is changed to _DEBUG (to match the setting in the exe).
与所有其他答案一样,我检查了我的
Configuration Properties -> C/C++->预处理器
指令。就我而言,我在发布中正确定义了
NDEBUG
,但我也有:_SECURE_SCL=1
。删除那个就解决了这个问题。
Like all the other answers, I checked my
Configuration Properties -> C/C++ -> Preprocessor
directives.In my case I had the
NDEBUG
correctly defined in Release, but I also had:_SECURE_SCL=1
.Removing that one fixed the issue.
对我来说这只是一个属性问题,将 C/C++ /code Generation/MDd 更改为 MD 解决了它
For me it's just a properties problem, change C/C++ /code generation/MDd to MD solved it
同上。我将发布级库链接到调试 EXE。
问题原因:我通过右键单击解决方案资源管理器中的项目,选择“添加→现有项目”并浏览到 .LIB 文件来包含 .LIB。
修复:改为转到项目属性。通过将不同的 .LIB 添加到列表中,在每个调试和发布中包含不同的 .LIB。转到链接器 ➔ 输入,然后添加适合配置的 .LIB 版本。
Ditto. I was linking a Release-level library to a Debug EXE.
Cause of problem: I had included the .LIB by right-clicking on the Project in Solution Explorer, choosing "Add ➔ Existing Item" and browsing to the .LIB file.
Fix: Go to Project Properties instead. Include a different .LIB in each of the Debug and Release by adding them to the list. Go to Linker ➔ Input, and add the version of the .LIB appropriate for the Configuration.
其中一个项目设置为调试,其他项目设置为在配置管理器中发布。在所有其他设置中都丢失了。
one of the projects is set to debug and others are set to release in configuration manager.. was lost in all other settings.
当 Qt 的插件将 qmake 项目转换为 Visual Studio C++ 项目时,我遇到了这个问题。由 vcpkg (gRPC) 管理的依赖项报告了该错误。报告的冲突发生在 gpr.lib(gRPC 的依赖项)和 CUDA 内核编译中的 OBJ 文件之间。不确定这是否重要。
我打开了详细链接器日志记录,发现它正在搜索 gRPC 的调试版本,然后也搜索了发布版本。
项目属性 \ 链接器 \ 常规 \ 显示进度 \ 显示所有进度消息 (/VERBOSE)
然后我偶然发现了 vcpkg 设置,发现有一个“Vcpkg 配置”选项,对于我的调试和发布配置都设置为“发布”。将“调试”配置设置为“调试”为我解决了这个问题。
I encountered this issue when Qt's plugin converted a qmake project to a Visual Studio C++ project. The error was being reported in a dependency managed by vcpkg (gRPC). The reported conflict was between gpr.lib (dependency of gRPC) and an OBJ file from a CUDA kernel compilation. Not sure if that is significant.
I turned on verbose linker logging and saw that it was searching debug versions of gRPC, and then also searched release versions as well.
Project properties \ Linker \ General \ Show Progress \ Display all progress messages (/VERBOSE)
Then I stumbled across the vcpkg settings and saw there was a "Vcpkg Configuration" option that was set to "Release" for both my Debug and Release configurations. Setting that to "Debug" for the "Debug" configuration resolved the issue for me.