Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
367 views
in Technique[技术] by (71.8m points)

c++ - error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj

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 SettingsAdministratorMy DocumentsVisual Studio 2010ProjectsTransformerDebugTester.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.0vcincludeutility(101): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because ptimizations are disabled in function
    1>c:userskasiadocumentsvisual studio 2010projectsclassificationframeworkclassificationframeworkdirectoryreader.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.0vcincludexstring(1589): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
    1>c:userskasiadocumentsvisual studio 2010projectsclassificationframeworkclassificationframeworksamplenamesset.cpp(226): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
    1>c:userskasiadocumentsvisual studio 2010projectsclassificationframeworkclassificationframeworkdirectoryreader.cpp(60): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
    1>c:userskasiadocumentsvisual studio 2010projectsclassificationframeworkclassificationframeworksamplenamesset.cpp(199): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
    1>c:userskasiadocumentsvisual studio 2010projectsclassificationframeworkclassificationframeworksampleset.cpp(27): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
    1>c:userskasiadocumentsvisual studio 2010projectsclassificationframeworkclassificationframeworksamplenamesset.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 SettingsAdministratorMy DocumentsVisual Studio 2010ProjectsTransformerReleasevc100.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 SettingsAdministratorMy DocumentsVisual Studio 2010ProjectsTransformerReleasevc100.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 SettingsAdministratorMy DocumentsVisual Studio 2010ProjectsTransformerReleasevc100.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 SettingsAdministratorMy DocumentsVisual Studio 2010ProjectsTransformerReleasevc100.pdb'; linking object as if no debug info
    1>  Tester.vcxproj -> C:Documents and SettingsAdministratorMy DocumentsVisual Studio 2010ProjectsTransformerReleaseTester.exe

I found that Debugger skips because of wrong path to pdb files.

'Tester.exe': Loaded 'C:Documents and SettingsAdministratorMy DocumentsVisual Studio 2010ProjectsWorkReleaseTester.exe', Symbols loaded.
'Tester.exe': Loaded 'C:WINDOWSSysWOW64kernel32.dll', Cannot find or open the PDB file
'Tester.exe': Unloaded 'C:WINDOWSSysWOW64kernel32.dll'
'Tester.exe': Loaded 'C:WINDOWSSysWOW64
tdll.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:WINDOWSSysWOW64kernel32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:OpenCV2.2inopencv_core220.dll', Binary was not built with debug information.
'Tester.exe': Loaded 'C:WINDOWSSysWOW64msvcp100.dll', Symbols loaded.
'Tester.exe': Loaded 'C:WINDOWSSysWOW64msvcr100.dll', Symbols loaded.
'Tester.exe': Loaded 'C:OpenCV2.2inopencv_highgui220.dll', Binary was not built with debug information.
'Tester.exe': Loaded 'C:WINDOWSSysWOW64user32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:WINDOWSSysWOW64gdi32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:WINDOWSSysWOW64advapi32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:WINDOWSSysWOW64
pcrt4.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:WINDOWSSysWOW64secur32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:WINDOWSSysWOW64ole32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:WINDOWSSysWOW64msvcrt.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:WINDOWSWinSxSx86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_5.82.3790.4770_x-ww_A689AB02comctl32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:WINDOWSSysWOW64avifil32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:WINDOWSSysWOW64winmm.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:WINDOWSSysWOW64msacm32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:WINDOWSSysWOW64msvfw32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:WINDOWSSysWOW64shell32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:WINDOWSSysWOW64shlwapi.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:WINDOWSSysWOW64avicap32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:WINDOWSSysWOW64version.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:OpenCV2.2inopencv_imgproc220.dll', Binary was not built with debug information.
'Tester.exe': Loaded 'C:WINDOWSSysWOW64imm32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:WINDOWSSysWOW64lpk.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:WINDOWSSysWOW64usp10.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:WINDOWSWinSxSwow64_Microsoft.Windows.Common-        Controls_6595b64144ccf1df_6.0.3790.4770_x-ww_8D2E3180comctl32.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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

_ITERATOR_DEBUG_LEVEL = 0 // disabled (for release builds)
_ITERATOR_DEBUG_LEVEL = 1 // enabled (if _SECURE_SCL is defined)
_ITERATOR_DEBUG_LEVEL = 2 // enabled (for debug builds)

In short you are probably mixing release and debug dlls. Don't linked release dlls in debug or vice versa!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...