Compilation and problem solving of gdal in Centos7.4,anaconda3,python3.6,tensorflow environment
This is the extra package that Gdal may use, and compiles it beforehand as needed.
Here I mainly use the Proj,libtiff,geotiff,geos,hdf5 these 5 bags, basically can meet the needs
Installation steps
Create a New Installation directory:
cd /home/Elammkdir gdalsrccd gdalsrc
Compiling additional packages: 1.proj
yum install gcc-c++wget http://download.osgeo.org/proj/proj-4.8.0.tar.gztar -zxvf proj-4.8.0.tar.gz cd proj-4.8.0mkdir build./configure --prefix=/home/Elam/gdalsrc/proj-4.8.0/build# compilemake -j# install into build dirmake install
Create a unified folder for adding environment variables:
cd /home/Elam/gdalsrcmkdir envshcd envshvim export_path.sh
Add the following two lines of code
export LD_LIBRARY_PATH="/home/Elam/gdalsrc/proj-4.8.0/build/lib:$LD_LIBRARY_PATH"export PATH="/hoem/Elam/gdalsrc/proj-4.8.0/build/bin:$PATH"
You can source export_path.sh and then type proj to see if the compilation was successful
2.libtiff
yum install gcc-c++ zlib-devel libjpeg-turbo-develcd /home/Elam/gdalsrcwget http://download.osgeo.org/libtiff/tiff-4.0.9.tar.gz 最新版本是4.0.9tar -zxvf tiff-4.0.9.tar.gzcd tiff-4.0.9
LS to find out that the build folder already exists, so you don't need to recreate the direct configure
./configure --prefix=/home/Elam/gdalsrc/tiff-4.0.9/build/ --exec-prefix=/home/Elam/gdalsrc/tiff-4.0.9/buildmake -jmake check# install to build dirmake install# confirm install./build/bin/tiffinfo
Enter the Export_path you just created to add a new environment variable, such as:
SOURCE a bit
3.Geotiff
Under the GDALSRC directory
wget http://download.osgeo.org/geotiff/libgeotiff/libgeotiff-1.4.2.tar.gztar -xvfz libgeotiff-1.4.2.tar.gz cd libgeotiff-1.4.2/mkdir build./configure --prefix=/home/Elam/gdalsrc/libgeotiff-1.4.2/build --with-proj=/home/Elam/gdalsrc/proj-4.8.0/build --with-libtiff=/home/Elam/gdalsrc/tiff-4.0.9/build --with-zlib --with-jpeg# compilemake -j# install into build dirmake install
Enter Export_path to add a new environment variable, such as:
SOURCE a bit
4.Geos
yum install gcc-c++ swig python-develcd /home/Elam/gdalsrcwget http://download.osgeo.org/geos/geos-3.6.2.tar.bz2tar -xvjf geos-3.6.2.tar.bz2 cd geos-3.6.2mkdir build./configure --prefix=/home/Elam/gdalsrc/geos-3.6.2/build --enable-python# compile make -j$threadsmake check# install into build dirmake install# check install./build/bin/geos-config --version
Gdal problems encountered during the compilation process are mainly in the compilation of this library
Error:
./configure--prefix=/home/elam/gdalsrc/geos-3.6.2/build--enable-python
Configure appears cannot find Python library path error:
Workaround:
Vim Configure
Enter/cannot find Python library path in the lower left corner
Enter
Locate the corresponding row near
[Image upload failed ...] (image-5ecfa3-1528652621967)]
Change the libpython$pythoh_version to your own. So and. A versions (specific versions can be viewed in the same path under the include path under the Lib folder)
Like I changed to libpython3.6m.
Modified: Wq
Re-configure
Continue to modify the Configure file
[Image upload failed ...] (image-a183a3-1528652621967)]
Re-configure
If subsequent also reported/usr/bin/ld:cannot find-lpython3.6 error
Continue to modify
Re-configure
And then continue
make –j make checkmake install
Add a new environment variable
Source
5.hdf5
yum install gcc-c++ zlib-develcd /home/Elam/gdalsrcwget http://www.hdfgroup.org/ftp/HDF5/current/src/hdf5-1.8.11.tar.gztar xvfz hdf5-1.8.11.tar.gzcd hdf5-1.8.11touch release_docs/INSTALL_VMS.txtmkdir buildCFLAGS=-O0 ./configure --prefix=/home/Elam/gdalsrc/hdf5-1.10.1/build --enable-shared --enable-build-all --with-zlib --with-pthread --enable-cxx # compilemake -j# test build -- all tests should passmake -j check# install into build dirmake install
Add a new environment variable, note that there is also an include folder
Gdal compiling
I got a 2.3 from the Internet. 0 version, URL: http://download.osgeo.org/gdal/
yum install subversion gcc-c++ sqlite-devel libxml2-devel python-devel numpy swig expat-devel libcurl-devel xerces-c-devel unixODBC-devel postgresql postgresql-develcd /home/Elam/gdalsrctar -zxvf gdal-2.3.0.tar.gzcd gdal-2.3.0mkdir build./configure --prefix=/home/Elam/gdalsrc/gdal-2.3.0/build --with-jpeg=external --without-libtool --with-python=/usr/local/anaconda3/bin/python --with-static-proj4=/home/Elam/gdalsrc/proj-4.8.0/build --with-libtiff=/home/Elam/gdalsrc/tiff-4.0.9/build --with-geotiff=/home/Elam/gdalsrc/libgeotiff-1.4.2/build --with-geos=/home/Elam/gdalsrc/geos-3.6.2/build/bin/geos-config --with-hdf5=/home/Elam/gdalsrc/hdf5-1.10.1/build make -j# install into build dirmake install
To add a new environment variable:
Into the build/bin inside.
gdal-config –-version
See if the compilation was successful
cd /home/Elam/gdalsrc/gdal-2.3.0/swigmake -jcd pythonpython setup.py install --prefix=/home/Elam/gdalsrc/gdal-2.3.0/build
Add environment variables, or add paths directly to SYS's path
Source
Re-create a new terminal
First Use
echo $PATHecho $LD_LIBRARY_PATH
See if the paths for each library are
If not, then re-source the export_path.sh if you do not want to re-source each time, add directly to the system's environment variables
Enter the Python terminal
See if I can import.
Compilation and problem solving of gdal in Centos7.4,anaconda3,python3.6,tensorflow environment