오류 LNK2038 : ‘_ITERATOR_DEBUG_LEVEL’에 대해 불일치가 감지되었습니다. 값 ‘0’이 (가) main.obj의 ‘2’값과 일치하지 않습니다. from local

내 문제에 대한 많은 해결책을 읽었지만 아무런 도움이되지 않았습니다. 나는 깨끗하고 재건을 시도했다. Visual 2010을 다시 설치하고 Professional에서 Ultimate으로 변경하십시오. 그러나 여전히이 오류가 발생하는 이유를 모르겠습니다. 내 프로젝트는 다음과 같습니다. 1 정적 라이브러리를 테스트하는 Exe Solution. 1 Dll 솔루션 정적 라이브러리. dll로 변환 된 코드는 ClassificationFramework라는 1 lib의 함수를 사용하고 있습니다. 나는이 lib를 헤더와 cpp로 기본적으로 소스 코드로 제공했다. Exe 솔루션에서 생성 된 라이브러리 + 다른 라이브러리를 연결하여 ClassificationFramework.dll을 실행했습니다. 릴리스를 사용할 때 모든 것이 잘 작동하지만 디버그로 변경하면 (일부 디버깅을 원하기 때문에 릴리스 모드에서 디버거를 건너 뛰는 데 피곤합니다) 다음과 같이 나타납니다.

    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

릴리스에서 빌드 할 때 다음 경고도 표시됩니다.

    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을 관리자로 실행하려고 시도했지만 너무 도움이되지 않았습니다. Microsoft 서버를 사용하여 pdb 파일을로드했지만 도움이되지 않았습니다.



답변

VS2010에서는 반복자 디버그 수준이 디버그에서 기본적으로 2로 설정되고 릴리스에서 비활성화됩니다. 사용중인 dll 중 하나는 이전 버전의 Visual Studio에서 빌드되었거나 프로젝트에 정의를 명시 적으로 추가했기 때문에 디버그에서 반복자 디버깅이 해제되었을 수 있습니다.

모든 프로젝트와 소스에서 검색 _ITERATOR_DEBUG_LEVEL하고 _SECURE_SCL제거하거나 적절하게 설정하고 모든 것을 재구성하십시오.

_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)

요컨대 릴리스 및 디버그 dll을 혼합하고있을 것입니다. 릴리스 dll을 디버그 또는 그 반대로 링크하지 마십시오!


답변

이전 Visual 6 프로젝트를 Visual Studio 2012로 마이그레이션 한 후 정적 라이브러리에 대해 링크하는 응용 프로그램에서 오늘 같은 오류가 발생했기 때문에이 문제에 대해 약간 업데이트했습니다.

필자의 경우 오류는 / MD 대신 / MDd를 사용 하여 정적 lib의 릴리스 버전을 실수로 컴파일하는 반면 응용 프로그램은 릴리스의 / MD 입니다. 정적 lib 프로젝트에서 올바른 / MD를 설정하면 문제가 해결되었습니다.

이것은 프로젝트 속성 에서 수행됩니다.

  • 선택 구성 속성 / C C ++ / 코드 생성을 트리에
  • 런타임 라이브러리 옵션 은 모든 종속성 프로젝트 및 응용 프로그램에서 동일하게 설정됩니다.

답변

릴리스의 프로젝트 A를 디버그의 다른 프로젝트 B와 의도적으로 연결하려면 디버깅하는 동안 응용 프로그램의 전반적인 성능 이점을 유지한다고 말하면이 오류가 발생할 수 있습니다. 프로젝트 B의 전 처리기 플래그를 임시로 수정하여 반복자 디버깅을 비활성화하고 프로젝트 A와 일치하게하여이 문제를 해결할 수 있습니다.

프로젝트 B의 “디버그”특성, 구성 특성-> C / C ++-> 전 처리기에서 전 처리기 정의에 다음을 추가하십시오.

_HAS_ITERATOR_DEBUGGING = 0; _ITERATOR_DEBUG_LEVEL = 0;

디버그에서 프로젝트 B를 다시 빌드 한 다음 릴리스에서 프로젝트 A를 빌드하면 올바르게 링크되어야합니다.


답변

프로젝트 사이에 불일치가 있습니다. 하나는 멀티 바이트 문자 세트이고 다른 하나는 유니 코드입니다. 유니 코드에 동의하도록이를 수정하면 문제가 해결되었습니다.


답변

동일한 실행 파일 또는 dll에서 디버그 빌드와 릴리스 빌드를 함께 혼합하면 오류가 발생할 수 있습니다.

  1. vs 구성 관리자에서 일부 프로젝트는 디버그 모드이고 일부는 릴리스 모드입니까?
  2. 릴리스 프로젝트 중 하나에 사전 처리기 기호 DEBUG 또는 _DEBUG가 정의되어 있습니까?
  3. 디버그 프로젝트 중 하나에 사전 처리기 기호 NDEBUG가 정의되어 있습니까?

답변

나도이 문제가 있었다.

내 문제는 라이브러리 포함 디렉토리를 디버그 구성에서 복사 / 붙여 넣었다는 것입니다.

따라서 “Indep”프로젝트에는 릴리스 된 경우에도 “../Debug”의 정적 라이브러리 “Dep.lib”가 포함되었습니다. 수정은 라이브러리 디렉토리를 “../Release”로 변경하여 이전에 빌드 된 디버그 라이브러리가 아닌 릴리스 빌드 라이브러리를 발견했습니다.


답변

디버그 라이브러리와 릴리스 라이브러리간에 동일한 문제가있었습니다. 솔루션 속성 / 구성 속성 / 구성에 실수가있었습니다.

프로젝트 구성이 기본 구성 / 플랫폼과 일치하지 않았습니다.