Generally, it's a good idea to use the GDAL MSVC binary distribution which contains the Debug and Release libraries, application binaries, data, and headers:
- gdal151-vc71.zip for VC7.1 (aka Visual Studio .NET 2003)
- gdal151-vc8.zip for VC8 (aka Visual Studio 2005)
However, there may be situations in which you want to compile GDAL yourself.
Here are the steps:
- If you don't already have them, acquire the library dependencies.
- libjpeg: Easiest is to simply grab headers and pre-built libraries from libjpeg-6b.zip (248K). If you really want to build it yourself, you can grab jpegsrc.v6b.tar.gz (600k) but it's not recommended as their build support dates from the 1990s.
- libpng/zlib: Easiest is to use headers and pre-built libraries from libpng-1.2.12.zip (533K). Alternately, you could build it from source from the libpng website.
- 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:
\APIs\libjpeg-6b
\APIs\libpng-1.2.8Library paths:
\APIs\libjpeg-6b
\APIs\libpng-1.2.8- 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.)
\APIs\libpng-1.2.8- Acquire GDAL. The download instructions are on the GDAL site.
- Download the Solution/Project files:
- gdal151_projects_vc71.zip for VC7.1
- gdal151_projects_vc8.zip for VC8
- Unzip it to your GDAL folder, e.g. "gdal-1.4.1", and it will create a folder, e.g. "gdal-1.4.1/VisualStudio<version>".
- Load the solution and build the gdal project.
For any questions, please email ben@vterrain.org or the GDAL mailing list.
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:
- 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.
- Add the Xerces headers and libraries to your MSVC include and library paths.
- Add the Xerces library (.lib) to the Linker Input settings.
- Add the preprocessor definite GML_ENABLED to the Compiler settings.