Changes between Version 19 and Version 20 of FAQInstallationAndBuilding


Ignore:
Timestamp:
Aug 24, 2023, 3:32:10 AM (8 months ago)
Author:
Even Rouault
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FAQInstallationAndBuilding

    v19 v20  
    11= [wiki:FAQ] - Installation and Building =
    22
    3 [[PageOutline(2,,inline)]]
    4 
    5 == Where can I find development version of GDAL? ==
    6 
    7 You can checkout it directly from SVN repository. Visit [http://trac.osgeo.org/gdal/wiki/DownloadSource#Subversion Downloading GDAL/OGR Source] Wiki page for detailed instructions.
    8 
    9 == Can I get a MS Visual Studio Project file for GDAL? ==
    10 
    11 The GDAL developers find it more convenient to [BuildingOnWindows 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.
    12 
    13 Currently, GDAL provides [wiki:GeneratingVisualStudioProject generate_vcxproj.bat] script to generate Makefile Project on demand.
    14 
    15 Occasionally 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.
    16 
    17 == Can I build GDAL with MS Visual C++ 2008 Express Edition? ==
    18 
    19 Yes, since at least GDAL/OGR 1.5 this should be straight forward. Before proceeding with the normal NMAKE based build just ensure that the MSVC_VER macro near the top of [source:trunk/gdal/nmake.opt gdal/nmake.opt] is changed to 1500 to reflect the compiler version (Visual C++ 9.0). This will modify the build to skip the VB6 interfaces which depend on ATL components not available in the express edition.
    20 
    21 [http://www.microsoft.com/express/download/ Microsoft Express Edition Downloads]
    22 
    23 == Can I build GDAL with MS Visual C++ 2005 Express Edition? ==
    24 
    25 Yes, you can. It's also possible to use GDAL libraries in applications developed using Microsoft Visual C++ 2005 Express Edition.
    26 
    27  * Download and install [http://msdn.microsoft.com/vstudio/express/visualc/download/ Visual C++ 2005 Express Edition]. Follow instructions presented on this website:
    28 
    29  * 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:
    30 
    31  * 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.
    32 
    33 {{{
    34 C:\\Program Files\\Microsoft Platform SDK\\Include\\atl
    35 C:\\Program Files\\Microsoft Platform SDK\\Include\\mfc
    36 }}}
    37 
    38  * 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:
    39   1. using the System applet available in the Control Panel
    40   2. by editing vsvars32.bat script located in
    41   {{{
    42   C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat
    43   }}}
    44 
    45  These variables should have following values assigned:
    46 
    47 {{{
    48 INCLUDE=C:\\Program Files\\Microsoft Visual Studio 8\\VC\\Include;
    49         C:\\Program Files\\Microsoft Platform SDK\\Include;
    50         C:\\Program Files\\Microsoft Platform SDK\\Include\\mfc;
    51         C:\\Program Files\\Microsoft Platform SDK\\Include\\atl;%INCLUDE%
    52 
    53 LIB=C:\\Program Files\\Microsoft Visual Studio 8\\VC\\Lib;
    54     C:\\Program Files\\Microsoft Visual Studio 8\\SDK\\v2.0\\lib;
    55     C:\\Program Files\\Microsoft Platform SDK\\lib;%LIB%
    56 }}}
    57 
    58  '''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.
    59 
    60  * Patch atlwin.h header
    61 
    62  At line 1725 add int i; declaration, so it looks as follows:
    63 
    64 {{{
    65 BOOL SetChainEntry(DWORD dwChainID, CMessageMap* pObject, DWORD dwMsgMapID = 0)
    66 {
    67     int i;
    68     // first search for an existing entry
    69 
    70     for(i = 0; i < m_aChainEntry.GetSize(); i++)
    71 }}}
    72 
    73  * Patch atlbase.h header
    74 
    75  At line 287, comment ''AllocStdCallThunk'' and ''FreeStdCallThunk'' functions and add macros replacements:
    76 
    77 {{{
    78 /***************************************************
    79 PVOID __stdcall __AllocStdCallThunk(VOID);
    80 VOID __stdcall __FreeStdCallThunk(PVOID);
    81 
    82 #define AllocStdCallThunk() __AllocStdCallThunk()
    83 #define FreeStdCallThunk(p) __FreeStdCallThunk(p)
    84 
    85 #pragma comment(lib, "atlthunk.lib")
    86 ***************************************************/
    87 
    88 /* NEW MACROS */
    89 #define AllocStdCallThunk() HeapAlloc(GetProcessHeap(),0,sizeof(_stdcallthunk))
    90 #define FreeStdCallThunk(p) HeapFree(GetProcessHeap(), 0, p)
    91 }}}
    92 
    93  * Building GDAL
    94    * Open console windows (Start -> Run -> cmd.exe -> OK)
    95    * If you have edited vsvars32.bat script, you need to run it using full path:
    96    {{{
    97    C:\> "C:\\Program Files\\Microsoft Visual Studio 8\\Common7\\Tools\\vsvars32.bat"
    98    Setting environment for using Microsoft Visual Studio 2005 x86 tools
    99    }}}
    100    * Go to GDAL sources root directory, for example:
    101    {{{
    102    C:\> cd work\gdal
    103    }}}
    104    * Run nmake to compile
    105    {{{
    106    C:\work\gdal> nmake /f makefile.vc
    107    }}}
    108    * If no errors occur, after a few minutes you should see GDAL libraries in C:\work\gdal.
    109 
    110 Now, you can use these libraries in your applications developed using Visual C++ 2005 Express Edition.
    111 
    112 == Can I build GDAL with Cygwin or MinGW? ==
    113 
    114 GDAL 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] and MSYS though there might be complications. The following might work:
    115 
    116 {{{
    117 ./configure --prefix=$PATH_TO_MINGW_ROOT --host=mingw32 \
    118         --without-libtool --without-python $YOUR_CONFIG_OPTIONS
    119 }}}
    120 
    121 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.
    122 
    123 Howto compile the (NG) Python bindings:
    124 
    125 {{{
    126 cd swig\python
    127 python setup.py build -c mingw32
    128 cp build\lib.win32-2.5\* c:\python25\lib\site-packages\
    129 }}}
    130 
    131 (some details may need adjusting)
    132 
    133 Howto compile the Perl bindings:
    134 
    135 {{{
    136 cd swig\perl
    137 perl Makefile.PL
    138 make.bat
    139 make.bat install
    140 }}}
    141 
    142 (the perl may need to be [http://www.adp-gmbh.ch/blog/2004/october/9.html compiled with MinGW])
    143 
    144 If you have swig, the bindings can be regenerated in MSYS prompt by command "make generate".
    145 
    146 == Can I build GDAL with Borland C or other C compilers? ==
    147 
    148 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 [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.
    149 
    150 == Why Visual C++ 8.0 fails with C2894 error in wspiapi.h when building GDAL with libcurl support? ==
    151 
    152 Here is the complete error message of this issue:
    153 {{{
    154 C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\wspiapi.h(44) :
    155    error C2894: templates cannot be declared to have 'C' linkage
    156 }}}
    157 
    158 This is a [http://curl.haxx.se/mail/tracker-2007-11/0027.html known bug] in the wspiapi.h header. One of possible solutions is to manually patch ''curl.h'' replacing lines '''153 - 154'''
    159 
    160 {{{
    161 #include <winsock2.h>
    162 #include <ws2tcpip.h>
    163 }}}
    164 
    165 with the following code:
    166 
    167 {{{
    168 #ifdef __cplusplus
    169 }
    170 #endif
    171 #include <winsock2.h>
    172 #include <ws2tcpip.h>
    173 #ifdef __cplusplus
    174 extern "C" {
    175 #endif
    176 }}}
    177 
    178 This problem occurs in [http://curl.haxx.se/libcurl/ libcurl] <= 7.17.1. Perhaps, later versions of libcurl will include this fix.
    179 
    180 == How can i add particular LDFLAGS with GDAL < 1.5 ==
    181 
    182 export the LNK_FLAGS variable with your habitual LDFLAGS content
    183 {{{
    184 export LNK_FLAGS=-Wl,-rpath=/foo/lib -l/foo/lib
    185 }}}
    186 
    187 == I am having problem building with external libraries, where can I look? ==
    188 
    189 There are additional hints and suggestions for building GDAL with various external support libraries in the BuildHints topic.
    190 
    191 == What is GDAL_DATA environment variable? ==
    192 
    193 GDAL_DATA is an [http://en.wikipedia.org/wiki/Environment_variable environment variable] used to specify location of [source:trunk/gdal/data supporting files] used by GDAL library as well as GDAL and OGR utilities. For instance, in order for OGR and GDAL to properly evaluate EPSG codes you need to have the EPSG support files (so called dictionaries, mostly in [http://en.wikipedia.org/wiki/Comma-separated_values CSV] format), like [source:trunk/gdal/data/gcs.csv gcs.csv] and [source:trunk/gdal/data/pcs.csv pcs.csv], found in the directory pointed by GDAL_DATA variable.
    194 
    195 == How to set GDAL_DATA variable? ==
    196 
    197 On Linux, assuming [source:trunk/gdal/data gdal/data] supporting files are installed under ''/usr/local/share/gdal/data'' and Bash-like shell, export the variable as follows:
    198 {{{
    199 $ export GDAL_DATA=/usr/local/share/gdal
    200 }}}
    201 Refer to manual of your shell to learn how to set the GDAL_DATA variable permanently.
    202 
    203 On Windows, assuming supporting files are located under ''C:\GDAL\data'', in order to set the variable in current console session:
    204 {{{
    205 C:\> set GDAL_DATA=C:\GDAL\data
    206 }}}
    207 It's also possible to set GDAL_DATA variable permanently, as system-wide variable, so it's always available. Follow the instructions of [http://support.microsoft.com/default.aspx/kb/310519 How To Manage Environment Variable] guide.
    208 
    209 When using GDAL/OGR installed from one of available binary packages, [http://trac.osgeo.org/osgeo4w/ OSGeo4W] or [http://fwtools.maptools.org/ FWTools], installers configure shell environments automatically setting GDAL_DATA variable to point correct location of supporting files. There is no need to follow the steps explained above.
     3See https://gdal.org/download.html