[Gdal-dev] Visual Studio 2005, GDAL and Manifests

Simon Perkins sy at perkins.net
Sun Oct 22 23:41:37 EDT 2006


Hi GDALers,

After bashing my head against the brick wall that is Visual Studio 2005 
for most of the day, I made a discovery that I figured I'd share with 
you guys to perhaps save some of you the same headaches...

The problem I have been getting is that I've been unable to compile 
applications in Visual Studio 2005 using the /MDd compile switch (link 
with the debug C runtime), when I link them against the GDAL library 
compiled with the /MD switch (link with the non-debug CRT, which is what 
the GDAL makefiles do). Doing this results in a "MSVCR80.DLL not found" 
error when I try to run the program. Compiling my code with /MD fixes 
things, but this is not the default for Visual Studio debug builds, and 
simply changing the switch to /MD breaks other things in the debug 
build. Trying to copy the MSVCR80.DLL file that comes with Visual Studio 
into my program's folder changes the error to "an application tried to 
load the C runtime incorrectly".

Officially, mixing code that uses /MDd with libraries that use /MD is 
not supported, so you won't find much help in the MS documentation. In 
practice however, this combination is almost impossible to avoid this if 
you use third party DLLs such as GDAL (often only available built with 
/MD) with your own code in the Visual Studio IDE. Anyway, after much 
searching and experimentation, I found the answer.

You MUST embed the manifest file that is generated by the GDAL 
compilation process into the GDAL DLL. It is NOT enough to simply have 
the gdal13.dll.manifest file in the same directory as the DLL. 
Previously I thought this was enough (and I updated the makefile.vc 
files to install this manifest file), but it isn't.

To embed the manifest use, the mt.exe tool:

 > mt -manifest gdal13.dll.manifest -outputresource:gdal13.dll;2

Probably the makefile.vc files should be updated to do this. I'll 
hopefully get to it in a few days time if nobody beats me to it...

Cheers,

Sy






More information about the Gdal-dev mailing list