Debug version of app with GDAL lib - linker problem - ITERATOR_DEBUG_LEVEL
|Reported by:||georgik||Owned by:||warmerdam|
When you try to debug application based on GDAL lib in Visual Studio 2010 then linker is throwing errors like:
error LNK2038: mismatch detected for _ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in something.obj
There is workaround for application: set /MD to linker command line. This switch will force linker to turn off enhanced security checker and it will turn ITERATOR_DEBUG_LEVEL to 0.
To solve this problem in proper way it is better to update nmake.opt and replace /MD with /MDd in case of DEBUG build. That will cause that GDAL will compile with compatible debug settings.
You need just to update two lines in nmake.opt:
OPTFLAGS= $(CXX_ANALYZE_FLAGS) /nologo /MDd /EHsc /Zi /W4 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /Fd$(GDAL_ROOT)\gdal$(VERSION).pdb /DDEBUG OPTFLAGS= /nologo /MDd /EHsc /GR /Zi /W4 /Fd$(GDAL_ROOT)\gdal$(VERSION).pdb /DDEBUG
Then rebuild GDAL.
nmake -f makefile.vc clean nmake -f makefile.vc MSVC_VER=1600 DEBUG=1
Debug mode in Visual Studio will work without problem.
My suggestion is to add check for VS 2010 and in case of VS 2010 and DEBUG set /MDd instead of /MD.
I wrote some notes about this problem to the article: http://georgik.sinusgear.com/2011/10/14/_iterator_debug_level-value-0-doesnt-match-value-2/