Building GDAL on Windows with Microsoft Visual C++

Historically, it was possible to distribute Debug/Release binaries of GDAL that were pre-built.  However since MSVC 8 (aka MSVC 2005), the awful "side-by-side assemblies" means that Debug binaries built on one computer will not work on another computer.  (Really, it is incredible that Microsoft broke this so badly.)  This means if you want to use GDAL in Debug mode with VC8 or later, you have to build it yourself.

If you happen to still be on VC7.1 (aka Visual Studio .NET 2003), you are in luck, because it is possible to download the GDAL MSVC binary distribution which contains the Debug and Release libraries, application binaries, data, and headers:

Otherwise, you will need to build GDAL yourself.

Here are the build steps:

  1. If you don't already have them, acquire the library dependencies.
    • libjpeg: Easiest is to simply grab headers and pre-built libraries from (248K).  If you really want to build it yourself, you can grab the JPEG source yourself, but it's not recommended as their build support dates from the 1990s.
    • libpng/zlib: Easiest is to use headers and pre-built libraries (for VC7.1 and VC9) from (533K).  If you are on any other compiler, you must build it from source from the libpng website.  You must have libpng/zlib binaries that are built with the exact same compiler as you will build GDAL with.
  2. Up to VC9, if you don't already have them, make sure the dependencies are on your include and library paths.
    • In MSVC, this is under "Tools - Options - Projects - VC++ Directories".
      (Paths will be different if you installed the libraries in different locations.)
      Includes files will be in the following directories:


    Library paths:


    If you are on VC10 or later, they unfortunately took away the ability to set include/library paths in the IDE, so you have to set them manually on every project. (Really, it is incredible that Microsoft broke this so badly.)

  3. Make sure the dependency DLLs are on your PATH.
    • Close MSVC, confirm your system PATH has all of the following, then restart MSVC.
      (Paths will be different if you installed the libraries in different locations, or installed different versions of the libraries.)


  4. Get the GDAL source.  The download instructions are on the GDAL site.
  5. Download the Solution/Project files appropriate for your GDAL version and compiler.
  6. Unzip it to your GDAL folder, e.g. "gdal-1.8.0", and it will create a folder, e.g. "gdal-1.8.0/VisualStudio<version>".
  7. Load the solution and build the gdal project.

For any questions, please email or the GDAL mailing list.

Optional: GML support

If you need to build OGR with support for reading GML, you will want a recent version of the Xerces library, for example 2.3 or newer.  Because Xerces is such a bloated beast of a library, GML support is disabled by default in the Project files above.  You can turn it on with these steps:

  1. In the solution browser, select the GML source files (gdal / Source Files / ogr / ogrsf_formats / gml) and change their property 'Excluded from build' from Yes to No.
  2. Add the Xerces headers and libraries to your MSVC include and library paths.
  3. Add the Xerces library (.lib) to the Linker Input settings.
  4. Add the preprocessor definite GML_ENABLED to the Compiler settings.