Changes between Initial Version and Version 1 of FAQInstallationAndBuilding


Ignore:
Timestamp:
Apr 22, 2007, 10:44:43 AM (17 years ago)
Author:
Mateusz Łoskot
Comment:

Created new page for FAQ Installation and Building

Legend:

Unmodified
Added
Removed
Modified
  • FAQInstallationAndBuilding

    v1 v1  
     1= [wiki:FAQ] - Installation and Building =
     2
     3[[PageOutline(2,,inline)]]
     4
     5== Can I get a MS Visual Studio Project file for GDAL? ==
     6
     7The GDAL developers find it more convenient to build with makefiles and the [http://msdn2.microsoft.com/en-us/library/dd9y37ha(vs.80).aspx 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.
     8
     9There 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.
     10
     11Occasionally other users do prepare full project files, and you may be able to get them by asking on the [http://lists.maptools.org/mailman/listinfo/gdal-dev/ 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.
     12
     13== Can I build GDAL with MS Visual C++ 2005 Express Edition? ==
     14
     15Yes, you can. It's also possible to use GDAL libraries in applications developed using [http://msdn.microsoft.com/vstudio/express/visualc/ Microsoft Visual C++ 2005 Express Edition].
     16
     17 * Download and install [http://msdn.microsoft.com/vstudio/express/visualc/download/ Visual C++ 2005 Express Edition]. Follow instructions presented on this website:
     18
     19 * Download and install [http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/ Microsoft Platform SDK]. Also, follow these instructions carefully without omitting any of steps presented there:
     20
     21 * Add following two paths to Include files in the Visual C++ IDE settings. Do it the same way as presented in [http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/ Step 3] from the website above.
     22
     23{{{
     24C:\\Program Files\\Microsoft Platform SDK\\Include\\atl
     25C:\\Program Files\\Microsoft Platform SDK\\Include\\mfc
     26}}}
     27
     28 * 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:
     29  1. using the System applet available in the Control Panel
     30  2. by editing vsvars32.bat script located in
     31  {{{
     32  C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat
     33  }}}
     34
     35 These variables should have following values assigned:
     36
     37{{{
     38INCLUDE=C:\\Program Files\\Microsoft Visual Studio 8\\VC\\Include;
     39        C:\\Program Files\\Microsoft Platform SDK\\Include;
     40        C:\\Program Files\\Microsoft Platform SDK\\Include\\mfc;
     41        C:\\Program Files\\Microsoft Platform SDK\\Include\\atl;%INCLUDE%
     42
     43LIB=C:\\Program Files\\Microsoft Visual Studio 8\\VC\\Lib;
     44    C:\\Program Files\\Microsoft Visual Studio 8\\SDK\\v2.0\\lib;
     45    C:\\Program Files\\Microsoft Platform SDK\\lib;%LIB%
     46}}}
     47
     48 '''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.
     49
     50 * Patch atlwin.h header
     51
     52 At line 1725 add int i; declaration, so it looks as follows:
     53
     54{{{
     55BOOL SetChainEntry(DWORD dwChainID, CMessageMap* pObject, DWORD dwMsgMapID = 0)
     56{
     57    int i;
     58    // first search for an existing entry
     59
     60    for(i = 0; i < m_aChainEntry.GetSize(); i++)
     61}}}
     62
     63 * Patch atlbase.h header
     64
     65 At line 287, comment ''AllocStdCallThunk'' and ''FreeStdCallThunk'' functions and add macros replacements:
     66
     67{{{
     68/***************************************************
     69PVOID __stdcall __AllocStdCallThunk(VOID);
     70VOID __stdcall __FreeStdCallThunk(PVOID);
     71
     72#define AllocStdCallThunk() __AllocStdCallThunk()
     73#define FreeStdCallThunk(p) __FreeStdCallThunk(p)
     74
     75#pragma comment(lib, "atlthunk.lib")
     76***************************************************/
     77
     78/* NEW MACROS */
     79#define AllocStdCallThunk() HeapAlloc(GetProcessHeap(),0,sizeof(_stdcallthunk))
     80#define FreeStdCallThunk(p) HeapFree(GetProcessHeap(), 0, p)
     81}}}
     82
     83 * Building GDAL
     84   * Open console windows (Start -> Run -> cmd.exe -> OK)
     85   * If you have edited vsvars32.bat script, you need to run it using full path:
     86   {{{
     87   C:\> "C:\\Program Files\\Microsoft Visual Studio 8\\Common7\\Tools\\vsvars32.bat"
     88   Setting environment for using Microsoft Visual Studio 2005 x86 tools
     89   }}}
     90   * Go do GDAL sources root directory, for example:
     91   {{{
     92   C:\> cd work\gdal
     93   }}}
     94   * Run nmake to compile
     95   {{{
     96   C:\work\gdal> nmake /f makefile.vc
     97   }}}
     98   * If no errors occur, after a few minutes you should see GDAL libraries in C:\work\gdal.
     99
     100Now, you can use these libraries in your applications developed using Visual C++ 2005 Express Edition.
     101
     102== Can I build GDAL with Cygwin or MinGW? ==
     103
     104GDAL should build with [http://www.cygwin.com/ Cygwin] using the Unix-like style build methodology. It is also possible to build with [http://www.mingw.org/ MinGW] though there are some complications. The following might work:
     105
     106{{{
     107./configure --prefix=$PATH_TO_MINGW_ROOT --host=mingw32 \
     108        --without-libtool --without-python $YOUR_CONFIG_OPTIONS
     109}}}
     110
     111Using external win32 libraries will often be problematic with either of these environments - at the least requiring some manual hacking of the GDALmake.opt file.
     112
     113== Can I build GDAL with Borland C or other C compilers? ==
     114
     115These 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 [http://www.gdal.org/cpl__port_8h.html gdal/port/cpl_port.h] file and you will need to prepare a [http://www.gdal.org/cpl__config_8h-source.html gdal/port/cpl_config.h] file appropriate to your platform. Using [http://trac.osgeo.org/gdal/browser/trunk/gdal/port/cpl_config.h.vc cpl_config.h.vc] as a guide may be useful.