OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.9k stars 2.55k forks source link

make uses wrong proj version #1706

Closed tomvantilburg closed 5 years ago

tomvantilburg commented 5 years ago

Expected behavior and actual behavior.

When trying to build both proj (6.1.0) and gdal (3.0.1) from source it is expected that the right proj library with a custom path can be given during configure. It turns out that in the make process, an existing older proj library is being used.

Steps to reproduce the problem.

cd /var/data/src/proj-6.1.0
./autogen.sh
./configure --prefix=/opt/proj-6.1 && make 
sudo make install

cd /var/data/src/libgeotiff-1.5.1
./configure --prefix=/opt/libgeotiff-1.5 --with-proj=/opt/proj-6.1 && make 
sudo make install

cd /var/data/src/gdal-3.0.1
./autogen.sh
./configure \
    --prefix=/opt/gdal-3.0 \
    --with-sfcgal=/opt/sfcgal-1.3/bin/sfcgal-config \
    --with-geos=/opt/geos-3.7/bin/geos-config \
    --with-proj=/opt/proj-6.1 \
    --with-geotiff=/opt/libgeotiff-1.5 \
    --with-python=/usr/bin/python3 \
    && make 

configure output seems ok:

..[snip]...
checking for PROJ >= 6 library... checking for proj_create_from_wkt in -lproj... yes
configure: proj.h found
..[snip]...
  SWIG Bindings:             python 

  PROJ >= 6:                 yes
  enable GNM building:       yes
  enable pthread support:    yes
  enable POSIX iconv support:yes
  hide internal symbols:     no
..[snip]...

however, the build stalls with:

..[snip]...
/usr/bin/ld: /var/data/src/gdal-3.0.1/.libs/libgdal.so: undefined reference to `proj_alter_name'
/usr/bin/ld: /var/data/src/gdal-3.0.1/.libs/libgdal.so: undefined reference to `proj_create_conversion_eckert_i'
/usr/bin/ld: /var/data/src/gdal-3.0.1/.libs/libgdal.so: undefined reference to `proj_create_conversion_miller_cylindrical'
..[snip]...

and ldd gives:

ldd -v /var/data/src/gdal-3.0.1/.libs/libgdal.so |grep proj
    libproj.so.13 => /usr/local/lib/libproj.so.13 (0x00007ff93cb16000)
    /usr/local/lib/libproj.so.13:

Operating system

Ubuntu 19.04

GDAL version and provenance

Fresh download from github release, both proj and gdal

rouault commented 5 years ago

I don't think we can do anything about that. /usr/local/lib is a standard location into which the linker searches library. So the solution is to avoid to have another proj version there too...

tomvantilburg commented 5 years ago

Ouch.. I thought that would have been circumvented by adding the --with-proj param. I don't understand though why it grabs v. 13 whereas the contents of /usr/local/lib shows:

libproj.a
libproj.la
libproj.so
libproj.so.13
libproj.so.13.1.0
libproj.so.13.1.1
libproj.so.15
libproj.so.15.1.0
rouault commented 5 years ago

Presumably because libproj.so is a symbolic link to libproj.so.13 ?

tomvantilburg commented 5 years ago

Correct, that was indeed linked to the older version. Got confused with a lot of different builds.

jgrocha commented 4 years ago

I use to make GDAL with previous version of PROJ libraries on /usr/lib/x86_64-linux-gnu (but not at /usr/local/lib).

I can't do it no more.

Right now, to build gdal against PROJ lib in /usr/local/lib I need to edit manually GDALmake.opt to make sure -L/usr/local/lib is the first folder on LIBS options (to make sure it appears before -L/usr/lib/x86_64-linux-gnu).

Instead of:

LIBS    =       $(SDE_LIB) -lcrypto -lpoppler -ljson-c -lfreexl -lqhull -lqhull -L/usr/lib/x86_64-linux-gnu -lgeos_c -lwebp  -lsqlite3 -lodbc -lodbcinst -lkmlbase -lkmldom -lkmlengine -lkmlxsd -lkmlregionator -lexpat -lxerces-c -lpthread -lopenjp2 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu/hdf5/serial -lnetcdf -lhdf5_hl -lhdf5 -lpthread -lsz -lz -ldl -lm -lcurl -L/usr/lib/x86_64-linux-gnu/hdf5/serial -lhdf5 -lmfhdfalt -ldfalt -logdi -lgif -lCharLS -ljpeg -ltiff -lpng -lpq -lzstd -L/usr/local/lib -lproj -lsqlite3  -lz -lpthread -lm -lrt -ldl  -lpcre $(KAK_LIBS) $(DWG_LIBS) $(CURL_LIB) \
                $(MRSID_LIBS) $(MRSID_LIDAR_LIBS) $(ECW_LIBS) $(INGRES_LIB) \
                $(PCIDSK_LIB) $(RASDAMAN_LIB) $(SOSI_LIB) \
                $(OPENCL_LIB) $(JVM_LIB) $(LIBICONV) $(FGDB_LIB) $(LIBXML2_LIB) $(MONGODB_LIB) \
                $(MONGOCXXV3_LIBS) $(JNI_LIB) $(HDFS_LIB)

I use:

LIBS    =       $(SDE_LIB) -L/usr/local/lib -lcrypto -lpoppler -ljson-c -lfreexl -lqhull -lqhull -L/usr/lib/x86_64-linux-gnu -lgeos_c -lwebp  -lsqlite3 -lodbc -lodbcinst -lkmlbase -lkmldom -lkmlengine -lkmlxsd -lkmlregionator -lexpat -lxerces-c -lpthread -lopenjp2 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu/hdf5/serial -lnetcdf -lhdf5_hl -lhdf5 -lpthread -lsz -lz -ldl -lm -lcurl -L/usr/lib/x86_64-linux-gnu/hdf5/serial -lhdf5 -lmfhdfalt -ldfalt -logdi -lgif -lCharLS -ljpeg -ltiff -lpng -lpq -lzstd -lproj -lsqlite3  -lz -lpthread -lm -lrt -ldl  -lpcre $(KAK_LIBS) $(DWG_LIBS) $(CURL_LIB) \
                $(MRSID_LIBS) $(MRSID_LIDAR_LIBS) $(ECW_LIBS) $(INGRES_LIB) \
                $(PCIDSK_LIB) $(RASDAMAN_LIB) $(SOSI_LIB) \
                $(OPENCL_LIB) $(JVM_LIB) $(LIBICONV) $(FGDB_LIB) $(LIBXML2_LIB) $(MONGODB_LIB) \
                $(MONGOCXXV3_LIBS) $(JNI_LIB) $(HDFS_LIB)