Opened 12 years ago

Closed 9 years ago

Last modified 6 years ago

#4291 closed defect (fixed)

Debug version of app with GDAL lib - linker problem - ITERATOR_DEBUG_LEVEL

Reported by: georgik Owned by: warmerdam
Priority: normal Milestone:
Component: ConfigBuild Version: 1.8.1
Severity: normal Keywords: VS201
Cc: Mateusz Łoskot


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 

OPTFLAGS=   /nologo /MDd /EHsc /GR /Zi /W4
 /Fd$(GDAL_ROOT)\gdal$(VERSION).pdb  /DDEBUG

Then rebuild GDAL.

nmake -f clean
nmake -f 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:

Change History (4)

comment:1 by Mateusz Łoskot, 12 years ago

This problem is well-known and has been discussed countless times

See ticket #3346

comment:2 by Mateusz Łoskot, 11 years ago

Cc: Mateusz Łoskot added

comment:3 by Jukka Rahkonen, 9 years ago

Resolution: wontfix
Status: newclosed

#3346 was closed by mloskot couple of weeks ago. Closing this as well.

comment:4 by Even Rouault, 6 years ago

Resolution: wontfixfixed

In 40242:

nmake.opt: use /MDd for OPTFLAGS for DEBUG=1 builds (fixes #7059, fixes #6384, fixes #4291, fixes #3346, fixes #1647, fixes #540)

Note: See TracTickets for help on using tickets.