Version 1 (modified by Mateusz Łoskot, 16 years ago) ( diff )

Created new page for FAQ Installation and Building

FAQ - Installation and Building

  1. Can I get a MS Visual Studio Project file for GDAL?
  2. Can I build GDAL with MS Visual C++ 2005 Express Edition?
  3. Can I build GDAL with Cygwin or MinGW?
  4. Can I build GDAL with Borland C or other C compilers?

Can I get a MS Visual Studio Project file for GDAL?

The GDAL developers find it more convenient to build with makefiles and the Visual Studio NMAKE utility. Maintaining a parallel set of project files for GDAL is too much work, so there are no full project files directly available from the maintainers.

There are very simple project files available since GDAL/OGR 1.4.0 that just invoke the makefiles for building, but make debugging somewhat more convenient. These are the makegdal71.sln and makegdal80.sln files in the GDAL root directory.

Occasionally other users do prepare full project files, and you may be able to get them by asking on the gdal-dev list. However, I would strongly suggest you just use the NMAKE based build system. With debugging enabled you can still debug into GDAL with Visual Studio.

Can I build GDAL with MS Visual C++ 2005 Express Edition?

Yes, you can. It's also possible to use GDAL libraries in applications developed using Microsoft Visual C++ 2005 Express Edition.

  • Download and install Microsoft Platform SDK. Also, follow these instructions carefully without omitting any of steps presented there:
  • Add following two paths to Include files in the Visual C++ IDE settings. Do it the same way as presented in Step 3 from the website above.
C:\\Program Files\\Microsoft Platform SDK\\Include\\atl
C:\\Program Files\\Microsoft Platform SDK\\Include\\mfc
  • Since you will build GDAL from command line using nmake tool, you also need to set or update INCLUDE and LIB environment variables manually. You can do it in two ways:
    1. using the System applet available in the Control Panel
    2. by editing vsvars32.bat script located in
      C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat

These variables should have following values assigned:

INCLUDE=C:\\Program Files\\Microsoft Visual Studio 8\\VC\\Include;
        C:\\Program Files\\Microsoft Platform SDK\\Include;
        C:\\Program Files\\Microsoft Platform SDK\\Include\\mfc;
        C:\\Program Files\\Microsoft Platform SDK\\Include\\atl;%INCLUDE%

LIB=C:\\Program Files\\Microsoft Visual Studio 8\\VC\\Lib;
    C:\\Program Files\\Microsoft Visual Studio 8\\SDK\\v2.0\\lib;
    C:\\Program Files\\Microsoft Platform SDK\\lib;%LIB%

NOTE: If you have edited system-wide INCLUDE and LIB variables, using System applet, every Console (cmd.exe) will have it properly set. But if you have edited them through vsvars32.bat script, you will need to run this script in the Console before every compilation.

  • Patch atlwin.h header

At line 1725 add int i; declaration, so it looks as follows:

BOOL SetChainEntry(DWORD dwChainID, CMessageMap* pObject, DWORD dwMsgMapID = 0)
    int i;
    // first search for an existing entry

    for(i = 0; i < m_aChainEntry.GetSize(); i++)
  • Patch atlbase.h header

At line 287, comment AllocStdCallThunk and FreeStdCallThunk functions and add macros replacements:

PVOID __stdcall __AllocStdCallThunk(VOID);
VOID __stdcall __FreeStdCallThunk(PVOID);

#define AllocStdCallThunk() __AllocStdCallThunk()
#define FreeStdCallThunk(p) __FreeStdCallThunk(p)

#pragma comment(lib, "atlthunk.lib")

#define AllocStdCallThunk() HeapAlloc(GetProcessHeap(),0,sizeof(_stdcallthunk))
#define FreeStdCallThunk(p) HeapFree(GetProcessHeap(), 0, p)
  • Building GDAL
    • Open console windows (Start -> Run -> cmd.exe -> OK)
    • If you have edited vsvars32.bat script, you need to run it using full path:
      C:\> "C:\\Program Files\\Microsoft Visual Studio 8\\Common7\\Tools\\vsvars32.bat"
      Setting environment for using Microsoft Visual Studio 2005 x86 tools
    • Go do GDAL sources root directory, for example:
      C:\> cd work\gdal
    • Run nmake to compile
      C:\work\gdal> nmake /f
    • If no errors occur, after a few minutes you should see GDAL libraries in C:\work\gdal.

Now, you can use these libraries in your applications developed using Visual C++ 2005 Express Edition.

Can I build GDAL with Cygwin or MinGW?

GDAL should build with Cygwin using the Unix-like style build methodology. It is also possible to build with MinGW though there are some complications. The following might work:

./configure --prefix=$PATH_TO_MINGW_ROOT --host=mingw32 \
	--without-libtool --without-python $YOUR_CONFIG_OPTIONS

Using external win32 libraries will often be problematic with either of these environments - at the least requiring some manual hacking of the GDALmake.opt file.

Can I build GDAL with Borland C or other C compilers?

These are not supported compilers for GDAL; however, GDAL is mostly pretty generic, so if you are willing to take on the onerous task of building an appropriate makefile / project file it should be possible. You will find most portability issues in the gdal/port/cpl_port.h file and you will need to prepare a gdal/port/cpl_config.h file appropriate to your platform. Using as a guide may be useful.

Note: See TracWiki for help on using the wiki.