[GIS] GDAL build from source throwing OpenSSL errors on Ubuntu

gdalUbuntu

I'm trying to get GDAL installed/up to date on my Ubuntu machine, and I can't seem to get it to work properly. I've been following this process: https://milkator.wordpress.com/2014/05/06/set-up-gdal-on-ubuntu-14-04/, which is the same as the one described in Installing gdal 1.9.0 on linux ubuntu server 10.04?, but when I run make, I get all of these undefined reference errors that all seem to have to do with OpenSSL (at end of question).

I've tried installing openssl, but it's already on the latest version. I've been able to find similar errors elsewhere, but they haven't been very helpful or related (e.g. https://tickets.opscode.com/browse/COOK-1406).

I also haven't been able to get up and running from the ubuntugis ppa in the way that I want. I've been able to install gdal-bin, but gdalinfo --version returns GDAL 1.10.1, released 2013/08/26 (current version is now 1.11.2), which would be less of a problem if it also included the gdal python scripts, like gdal2tiles.py, which are what I'm ultimately after a working version of. They're not in /usr/bin, and I'm not sure where else to look.

I'm honestly not sure whether this is a problem with make, gdal, my machine, or something else entirely.

Errors from make:

make[1]: Entering directory `/home/MY_USER_FOLDER/sourceBuild/gdal-1.11.2/apps'
/bin/bash /home/MY_USER_FOLDER/sourceBuild/gdal-1.11.2/libtool --mode=link  g++  gdalinfo.lo commonutils.lo  /home/MY_USER_FOLDER/sourceBuild/gdal-1.11.2/libgdal.la -o gdalinfo
libtool: link: g++ .libs/gdalinfo.o .libs/commonutils.o -o .libs/gdalinfo  /home/MY_USER_FOLDER/sourceBuild/gdal-1.11.2/.libs/libgdal.so -L/usr/lib -L/home/MY_USER_FOLDER/anaconda3/lib -lgeos_c /home/MY_USER_FOLDER/anaconda3/lib/libsqlite3.so -lodbc -lodbcinst /usr/lib/x86_64-linux-gnu/libexpat.so -lxerces-c -ljasper -lnetcdf /home/MY_USER_FOLDER/anaconda3/lib/libhdf5.so /usr/lib/libmfhdfalt.so /usr/lib/libdfalt.so -lgif /home/MY_USER_FOLDER/anaconda3/lib/libjpeg.so /home/MY_USER_FOLDER/anaconda3/lib/libpng15.so -lpq -lpthread -lrt -lpcre /home/MY_USER_FOLDER/anaconda3/lib/libxml2.so -lm -lz -ldl  -Wl,-rpath -Wl,/home/MY_USER_FOLDER/anaconda3/lib
/usr/lib/libpq.so: undefined reference to `SSL_CTX_new@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_CTX_get_cert_store@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_check_private_key@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `CRYPTO_num_locks@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `ENGINE_by_id@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_CTX_use_certificate_chain_file@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `ERR_get_error@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `CRYPTO_set_locking_callback@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_use_certificate_file@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `TLSv1_method@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `ENGINE_free@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_new@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_load_error_strings@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `OPENSSL_config@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_get_error@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `X509_NAME_get_text_by_NID@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_write@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_use_PrivateKey_file@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `X509_STORE_load_locations@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `X509_free@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_CTX_load_verify_locations@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_free@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_ctrl@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_set_ex_data@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_set_verify@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `ENGINE_init@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_set_fd@OPENSSL_1.0.0'
/home/jeremy/sourceBuild/gdal-1.11.2/.libs/libgdal.so: undefined reference to `sqlite3_column_table_name'
/usr/lib/libpq.so: undefined reference to `SSL_read@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `ERR_reason_error_string@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_connect@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_CTX_ctrl@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_use_PrivateKey@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `X509_STORE_set_flags@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_pending@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `ENGINE_finish@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `ENGINE_load_private_key@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_library_init@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `X509_get_subject_name@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `CRYPTO_set_id_callback@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_shutdown@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_get_peer_certificate@OPENSSL_1.0.0'
collect2: error: ld returned 1 exit status
make[1]: *** [gdalinfo] Error 1
make[1]: Leaving directory `/home/jeremy/sourceBuild/gdal-1.11.2/apps'
make: *** [apps-target] Error 2

UPDATE: I created a virtual machine from a new Ubuntu 14.04 iso, and building from source there didn't give me any trouble. I'm beginning to wonder if it has something to do with my Anaconda installation, since this is the only reference to SSL in my config.log:

/home/jeremy/anaconda3/lib/libcurl.so: undefined reference to `SSLv2_client_method'

Best Answer

You shouldn't need to build from source to get a recent GDAL installed on Ubuntu. Don't bother with the UbuntuGIS-Stable PPA, use UbuntuGIS-Unstable. Unstable in this case does not mean buggy and shouldn't be used, it just means it is updated more frequently. The UbuntuGIS Stable PPA has not even been updated for the most recent Ubuntu LTS (14.04) which was released nearly a year ago...

Once you have added the unstable PPA, you need to install the gdal binaries AND the gdal python bindings:

sudo apt-get install gdal-bin python-gdal

To answer your question as asked... An easy way to get all the build dependencies for gdal if you really need to build from source, (i.e. if you need to modify the build to include ECW or other proprietary format support) is to add the unstable PPA, then install build dependencies via apt-get:

sudo apt-get build-dep gdal