Software
Documentation
Development
Discovering modelling
Software
Documentation
Development
Discovering modelling
To install CYGWIN on windows follow this guide and also ensure that; (1) the latest GCC is installed, (2) wget and cmake are also installed. To have a quick check of which packages are installed just type the following in a Cygwin command prompt:
cygcheck -c -d
After the Cygwin installer completes, it’s very important to keep the installer around. The installer is an executable named either setup-x86.exe
or setup-x86_64.exe
, and you’ll need it to add or remove Cygwin packages in the future. I suggest moving the installer to the same folder where you installed Cygwin itself; typically C:\cygwin
or C:\cygwin64
.
Now let's install the GDAL source code.
/home
directorywget “link to gdal source code”
wget http://download.osgeo.org/gdal/1.11.2/gdal-1.11.2.tar.gz
./configure
command to check some details about the machine on which the software is going to be installed and create a Makefile
. When you run the configure script you would see a lot of output on the screen , each being some sort of question and a respective yes/no as the reply. If any of the major requirements are missing on your system, the configure script would exit and you cannot proceed with the installation, until you get those required things. For a lighter build up (i.e. without -libtool) type./configure --prefix=$HOME --with-libz=internal --with-python=no --with-jasper=no --with-threads=yes --without-libtool --enable-fast-install
make
. Basically the make
utility compiles all your program code and creates the executables..bashrc
file. Open the .bashrc file with a text editor and add;export PATH=$PATH:$HOME/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/usr/local/lib:$HOME/lib export MANPATH=$MANPATH:$HOME/man
Log out and log back in again
Check that the paths have changed:
echo $LD_LIBRARY_PATH
You should get something /usr/lib:/usr/local/lib:/ouce-home/staff/cenv0222/lib
but with your username, of course.
Lets test if GDAL is now properly installed under Cygwinx64. Copy the following C++ script into a file named gdal_test.cpp
and save it into a folder within our home directory i.e. /home/GDALTest/gdal_test.cpp
. This script just load GDAL drivers and inform us when is done.
#include <iostream> using namespace std; #include "gdal_priv.h" int main () { cout << "Started...\n"; // Register all available GDAL drivers GDALAllRegister(); cout << "GDAL drivers loaded\n"; return 0; }
From a Cygwin terminal go to the folder where gdal_test.cpp
is located and just type g++ gdal_test.cpp -o gdal_test
. I got this error message back:
/tmp/ccGpf0Oa.o: In function `main': gdal_test.cpp:(.text+0x14): undefined reference to `GDALAllRegister' collect2: error: ld returned 1 exit status
which means that the thing compiled OK, but the linker (ld) couldn't find the GDAL library to link it in with our test program. Which is not surprising, we have to specify the location of the GDAL libraries.
GDAL provides a tool called gdal-config to do this.
So we run:
gdal-config
I got this output:
Usage: gdal-config [OPTIONS] Options: [--prefix[=DIR]] [--libs] [--dep-libs] [--cflags] [--datadir] [--version] [--ogr-enabled] [--formats]
We want it to tell us where the libs are, so we run:
gdal-config --libs
I got this output:
$ -L/usr/lib64 -lgdal
which is the location of the GDAL libraries on my laptop (you will probably get something different). This output is ready-formatted for the g++ compiler, which is convenient. So now we run:
g++ gdal_test.cpp -L/usr/lib64 -lgdal -o gdal_test
and the program should build with no error messages. Check that the executable file gdal_test is there, then run it.
./gdal_test
You should get this output:
Started... GDAL drivers loaded
If you compile but get a missing libgdal.dll
you might need to install the shared and static libraries manually:
cp libgdal.dll ../../home/bin/ cp libgdal.a ../../home/lib/
Try to run again ./gdal_test
and this should do the trick.
I have came accroos the error below error message when creating the executables by the make utility.
/home/apg1e14/GDAL/gdal-1.11.2/frmts/o/.libs/dgif_lib.o: In function `DGifOpenFileHandle': /home/apg1e14/GDAL/gdal-1.11.2/frmts/gif/giflib/dgif_lib.c:111: undefined reference to `setmode' /home/apg1e14/GDAL/gdal-1.11.2/frmts/gif/giflib/dgif_lib.c:111:(.text+0x8e1): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `setmode' /home/apg1e14/GDAL/gdal-1.11.2/frmts/o/.libs/egif_lib.o: In function `EGifOpenFileHandle': /home/apg1e14/GDAL/gdal-1.11.2/frmts/gif/giflib/egif_lib.c:137: undefined reference to `setmode' /home/apg1e14/GDAL/gdal-1.11.2/frmts/gif/giflib/egif_lib.c:137:(.text+0x4c7): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `setmode' collect2: error: ld returned 1 exit status GNUmakefile:41: recipe for target 'libgdal.la' failed make[1]: *** [libgdal.la] Error 1 make[1]: Leaving directory '/home/apg1e14/GDAL/gdal-1.11.2' GNUmakefile:50: recipe for target 'check-lib' failed make: *** [check-lib] Error 2
If this happen to you, it is recommended that you run make clean
which deletes all the already compiled object files. If you google this error you will find plenty of causes and solutions. I solved just by run the Cygwin installer to reinstall/update all packages (takes quite a long time but ensures that I was not missing any important package).