Learn Gdal words recommended two sites.
Gdal's Official document: www.gdal.org
Li Minhu Teacher's blog: http://blog.csdn.net/liminlu0314/article/category/777646
Let's get down to the chase.
The author's system is RHEL4.
It is a good practice to suggest that Linux users are accustomed to non-root operations, which can be helpful at work.
First install the Gdal dependent libraries proj.4 and geos.
Proj.4 is a library that provides operations related to the projection coordinate system, and GEOS is a library that provides spatial analysis calculations. are open source projects, you can Google the latest.
Because it is non-root, you need to create your own proj and GEOS directories (preferably with a version number) in the ~/local/directory. The current operating directory is then redirected to the root directory of the PROJ.4 project, such as/.../proj-4.8.0, after decompression. Next the source installation trilogy.
./configure--prefix=/home/users/yourname/local/proj-4.8. 0 --without-jnimake doinstall
When configuring, be sure to configure the installation path, because there is no root permission, if the direct installation will fail. The installation path is the directory created above. Here the author of the machine because if it contains JNI compiler will error, so in the configuration of the time to remove it. The cause may be a version or Java configuration issue. Anyway, I used C + + to use Gdal. There will be more than a try, if you can directly compile the success, then you do not need the following options.
Then is the installation of GEOS, the same steps.
./configure--prefix=/home/users/yourname/local/geos-3.4. 2 Make Make Install
After installing the dependent library, you begin to formally install Gdal.
Or jump to the extracted project root directory, and then the trilogy.
./configure--prefix=/home/users/yourname/local/gdal-1.11. 1 --with-geos=/home/users/yourname/local/geos-3.4. 2/bin/geos-configmake makeinstall
This explains that if you see GeoS support:yes after executing the first line of statements, it proves that Gdal has the support of the GEOS library, otherwise some features in the Gdal library will not work properly.
Here the author of the machine again has a problem: unable to compile through. Reported a bug about Cpl_virtualmem.cpp, through some find the system's Mremap function parameters and the inconsistency in this file, so manually modify the source code. Comment out the macro definition (below) in the cpl_virtualmem.cpp.
#define Have_5args_mremap
If you can directly compile the pass, you can ignore the above verbose.
This installs the process basically completes, below starts configures some development needs the environment.
Since Gdal is dynamically loaded for proj.4, add the proj.4 dynamic link library path to the variable ld_library_path and add the Gdal bin path to the variable path.
First open the ~/.BASHRC file with vim and add the following code at the end.
Export path= $PATH:/home/users/yourname/local/gdal-1.11. 1/binexport ld_library_path= $LD _library_path:/home/users/yourname/local/gdal-1.11. 1/lib:/home/users/yourname/local/proj-4.8. 0/lib
After the save exits, executing the source ~/.BASHRC does not actually update the variable.
Then enter Gdalinfo carriage return on the command line if a message appears indicating that the installation was successful.
Here's how to invoke the Gdal library using C + +.
First, create a new GDALTest.cpp file with the following content.
1#include"gdal.h"2#include"Ogrsf_frmts.h"3 4 intMainintargcChar*argv[])5 {6 Registerogrtab ();7 8Ogrsfdriverregistrar *registrar =Ogrsfdriverregistrar::getregistrar ();9 intCount =registrar->Getdrivercount ();Tenprintf"Total:%d\n", count); One for(intI=0; i<count;i++){ Aprintf"%s\n", Registrar->getdriver (i)GetName ()); - } - the return 0; -}
This code means the output OGR driver.
It is then compiled.
g++ Gdaltest. CPP -I./-i/home/users/yourname/local/gdal-1.11. 1/include-l/home/users/yourname/local/gdal-1.11. 1/lib-lgdal-o gdaltest
The last execution./gdaltest, if you see the normal output, indicates success.
How to install and use Gdal Library in Linux under non-root permissions