Compiling GDAL

Custom information about compiling the GDAL external dependency

Windows

The GDAL source files can be found on this page:
https://trac.osgeo.org/gdal/wiki/DownloadSource

Or here
http://download.osgeo.org/gdal/

The folders that are tested and work are gdal2.1.0 and gdal2.1.0beta1

Description on how to compile on windows can be found here:
https://trac.osgeo.org/gdal/wiki/BuildingOnWindows

Changing the Script File

The lines that need to be changed in the nmake.opt file before running the compilation script are:

Line 48

MSVC_VER=1900
Or whatever version of Visual Studio is used.

Line 64

GDAL_HOME = "C:\warmerda\bld"
Can be changed to another directory if desirable.

Line 203

WIN64=YES
Uncomment if commented. We compile for 64 bit for the purpose of OpenSpace.

Line 579 onwards

We use GDAL to open WMS datasets which requires it to link cURL.
Since cURL is dynamically linked in OpenSpace, we can use the same dll and include directory.
Another option is to download and compile cURL separately. Now we will have to physically
copy the cURL dll file to the bin folder of GDAL (Might not be the best way to do it?)

# Uncomment to use libcurl (DLL by default)
# The cURL library is used for WCS, WMS, GeoJSON, SRS call importFromUrl(), WFS, GFT, CouchDB, /vsicurl/ etc.
CURL_DIR = (Your path to OpenSpace-Development)\ext\curl\lib
CURL_INC = -I (Your path to OpenSpace-Development)\ext\curl\include
# Uncomment following line to use libcurl as dynamic library
CURL_LIB = $(CURL_DIR)\libcurl_imp.lib wsock32.lib wldap32.lib winmm.lib
# Uncomment following two lines to use libcurl as static library
#CURL_LIB = $(CURL_DIR)/libcurl.lib wsock32.lib wldap32.lib winmm.lib
#CURL_CFLAGS = -DCURL_STATICLIB

Running the Compilation Script

When the environment is set up, open VS2016 x64 Native Tools Command Prompt and run
nmake /f makefile.vc
in the GDAL folder.

To compile the binaries, run
nmake /f makefile.vc install

To compile the development libraries, run
nmake /f makefile.vc devinstall

Set up the GDAL_DATA variable

For GDAL to be able to read some of the map formats, it needs to know where the data folder can be found.
Set GDAL_DATA to point at the directory where the csv files can be found. If you downloaded the gdal-2.1.0 folder, it can be found in \gdal-2.1.0\data.
Visual Studio and any command prompt need to be restarted for the change to have an effect.

Possible Issuses When Compiling

  • If built with incorrect settings such as WIN64=NO and trying to recompile after the change might still result in architecture errors. If it does, remove the files and start over.
  • Currently, the only version we have tested and know works is gdal-2.1.0beta1. gdal-2.1.0 Resulted in compile errors for some unknown reason.

Testing if GDAL Supports WMS

Copy libcurl.dll from (Your path to OpenSpace-Development)\ext\curl\lib to GDAL_HOME\bld\bin (C:\warmerda\bld\bin if the path was not changed).

Go to the directory GDAL_HOME\bld\bin and run gdalinfo.exe --formats.

The WMS format should show up in the list.

Copy GDAL to OpenSpace

The current temporary solution is to copy gdal201.dll from the bin folder to the OpenSpace compilation directory.

Testing in OpenSpace

Running the test GdalWmsTest should not fail if everything works correctly.
(The test is currently only in our git branch feature/globebrowsing)

OSX

Linux