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

gdal 2.3.2 fails to build frmts/pdf and frmts/openjpeg with missing definition of LD_SHARED in GNUmakefile. #1454

Closed dreirund closed 5 years ago

dreirund commented 5 years ago

I am trying to build gdal 2.3.2 from source, using the official Arch Linux package (http://archlinux.org/packages/community/x86_64/gdal/) as a recipe, but changing ./configure-options.

When the build process reaches frmts/pdf or frmts/openjpeg, the build fails on make plugin, missing a definition of the variable LD_SHARED.

Example: Executing make plugin in frmts/openjpeg, prints the following to the terminal:

/bin/sh /home/felics/tmp/install/build/gdal/src/gdal-2.3.2/libtool --mode=compile --silent --tag=CXX g++ -DHAVE_AVX_AT_COMPILE_TIME -DHAVE_SSSE3_AT_COMPILE_TIME -DHAVE_SSE_AT_COMPILE_TIME -g -O2  -Wall -Wextra -Winit-self -Wunused-parameter -Wformat -Werror=format-security -Wno-format-nonliteral -Wlogical-op -Wshadow -Werror=vla -Wdate-time -Wnull-dereference -Wduplicated-cond -Wextra-semi -Wfloat-conversion -Wmissing-declarations -Wnon-virtual-dtor -Woverloaded-virtual -fno-operator-names -Wzero-as-null-pointer-constant -Wsuggest-override -Wimplicit-fallthrough  -I.. -DGNM_ENABLED -I/home/felics/tmp/install/build/gdal/src/gdal-2.3.2/port -I/usr/include/webp/include -I/usr/include/ -I/usr/include//include -I/usr/include/openjpeg-2.3  -I/usr/include/jasper -I/usr/include/jasper/include -I/usr/include -I/usr/include -I/usr/include/include -I/usr/include -I/usr/include/include -I/usr/include -I/usr/include/include -I/usr/include -I/usr/include/include  -DGDAL_COMPILATION -DHAVE_XERCES -I/usr/include -I/usr/include/xercesc -I/home/felics/tmp/install/build/gdal/src/gdal-2.3.2/port -I/usr/include/webp/include -I/usr/include/ -I/usr/include//include -I/usr/include/openjpeg-2.3  -I/usr/include/jasper -I/usr/include/jasper/include -I/usr/include -I/usr/include -I/usr/include/include -I/usr/include -I/usr/include/include -I/usr/include -I/usr/include/include -I/usr/include -I/usr/include/include  -DGDAL_COMPILATION  -c -o openjpegdataset.o openjpegdataset.cpp
openjpegdataset.o -L/usr/lib -lgdal  -lcrypto -lcryptopp -larmadillo -lproj -lfreexl -L/usr/lib -lgeos_c -L/usr/include/webp/lib -lwebp -L/usr/include/ -L/usr/include//lib -lodbc -lodbcinst -lexpat -lxerces-c -lpthread -lopenjp2  -L/usr/include/jasper -L/usr/include/jasper/lib -ljasper -L/usr/lib -lnetcdf -lhdf5 -L/opt/hdf4/lib -lmfhdf -ldf -L/usr/include -L/usr/include/lib -lgif -lCharLS -L/usr/include -L/usr/include/lib -ljpeg -lgeotiff -ltiff -lpng -L/usr/include -L/usr/include/lib -lcfitsio -L/opt/grass/lib -lgrass_vector -lgrass_dig2 -lgrass_dgl -lgrass_rtree -lgrass_linkm -lgrass_dbmiclient -lgrass_dbmibase -lgrass_raster -lgrass_imagery -lgrass_gproj -lgrass_gmath -lgrass_gis -lgrass_datetime -L/usr/lib -lpq -lzstd -llzma -lz -L/usr/include -L/usr/include/lib -lpthread -lm -lrt -ldl  -lspatialite -lsqlite3 -lrasterlite2 -lsqlite3 -lpcre   -lcurl   -lNCSEcw -lNCSEcwC -lNCSCnet -lNCSUtil     -lOpenCL    -lxml2 -lz -llzma -licui18n -licuuc -licudata -lm -ldl  -L/usr/lib/ -lmariadb -lz -ldl -lm -lpthread -lssl -lcrypto -L/usr/lib -lkea  -L/usr/lib -lhdf5_cpp -lhdf5 -lsz -lz -ldl -lm  \
-o gdal_JP2OpenJPEG.so
make: openjpegdataset.o: Command not found
make: *** [GNUmakefile:20: gdal_JP2OpenJPEG.so] Error 127

The corresponding lines of the GNUmakefiles in these directories are:

For frmts/pdf/GNUmakefile:

include ../../GDALmake.opt

OBJ     =       pdfdataset.o pdfio.o pdfobject.o pdfcreatecopy.o ogrpdflayer.o pdfwritabledataset.o pdfreadvectors.o

[...]

plugin: $(PLUGIN_DL)

$(PLUGIN_DL):  $(OBJ)
        $(LD_SHARED) $(OBJ) ../../ogr/ogrsf_frmts/o/ogrmemdatasource.o ../../ogr/ogrsf_frmts/o/ogrmemdriver.o ../../ogr/ogrsf_frmts/o/ogrmemlayer.o $(LDFLAGS) $(CONFIG_LIBS) -o $(PLUGIN_DL) $(PDFIUM_PLUGIN_LIB) $(POPPLER_PLUGIN_LIB) $(PODOFO_PLUGIN_LIB)

(The full frmts/pdf/GNUmakefile I have uploaded there: http://ix.io/1GvT)

frmts/openjpeg/GNUmakefile is:


include ../../GDALmake.opt

OBJ     =       openjpegdataset.o

CPPFLAGS        :=       -I.. $(CPPFLAGS)

default:        $(OBJ:.o=.$(OBJ_EXT))

clean:
        rm -f $(OBJ) $(O_OBJ) *.so *.lo

install-obj:    $(O_OBJ:.o=.$(OBJ_EXT))

PLUGIN_SO = gdal_JP2OpenJPEG.so

plugin: $(PLUGIN_SO)

$(PLUGIN_SO): $(OBJ)
        $(LD_SHARED) $(LNK_FLAGS) $(OBJ) $(CONFIG_LIBS_INS) $(LIBS) \
        -o $(PLUGIN_SO)

The GDALmake.opt, which is included by the frmts/*/GNUmakefiles, contains a statement

LD_SHARED       =       

and does not try to set LD_SHARED somewhere else. The complete GDALmake.opt I have uploaded there: http://ix.io/1GvU

It seems that LD_SHARED is not set, and so make plugin tries to execute the command $(OBJ) ../../ogr/ogrsf_frmts/o/ogrmemdatasource.o ../../ogr/ogrsf_frmts/o/ogrmemdriver.o ../../ogr/ogrsf_frmts/o/ogrmemlayer.o $(LDFLAGS) $(CONFIG_LIBS) -o $(PLUGIN_DL) $(PDFIUM_PLUGIN_LIB) $(POPPLER_PLUGIN_LIB) $(PODOFO_PLUGIN_LIB), which obviously will fail, since the first element in $(OBJ) is not an executable.

Here more detailed information about how I go about:

I am working on Arch/ Artix Linux.

I use the following steps to build gdal, in this order (taken from the official Arch Linux package's PKGBUILD http://archlinux.org/packages/community/x86_64/gdal/):

  1. For a clean environment, I set CFLAGS='' CXXFLAGS='' LDFLAGS=''
  2. downloading and extracting https://download.osgeo.org/gdal/2.3.2/gdal-2.3.2.tar.xz
  3. downloading patches:
  4. Applying fixes and patches, in this order, commands carried out from within the source directory of extraction:
    • Fix build with poppler >= 0.69.0 patch -Np2 -i ../gdal-poppler-0.69.0.patch
    • Fix build with poppler 0.72 find frmts/pdf -type f | xargs sed -e 's|GBool|bool|g' -e 's|gFalse|false|g' -e 's|getCString|c_str|g' -i
    • Fix build with poppler 0.73 sed -e 's|#include <goo/gtypes.h>|typedef unsigned char Guchar;|' -i frmts/pdf/pdfsdk_headers.h
    • Fix build with poppler 0.75 patch -p2 -i ../gdal-poppler-0.75.patch
    • Fix mandir sed -i "s|^mandir=.*|mandir='\${prefix}/share/man'|" configure
    • Fix Perl bindings installation path patch -Np1 -i ../gdal-perl-vendor.patch (Up to here, I have changed nothing from the official Arch Linux package.)
  5. Configuring the build:
    ./configure --prefix=/usr --with-netcdf --with-libtiff --with-sqlite3 --with-geotiff  \
              --with-mysql --with-curl --with-hdf5 --with-perl --with-geos  \
              --with-png --with-poppler --with-spatialite --with-openjpeg  \
              --enable-pdf-plugin \
              --with-libz='/usr/include' \
              --with-liblzma \
              --with-pg='/usr/bin/pg_config' \
              --with-zstd=yes \
              --with-grass='/opt/grass' --with-libgrass='/opt/grass/include/grass' \
              --with-cfitsio='/usr/include' \
              --with-pcraster=internal \
              --with-dds=no \
              --with-gta=no \
              --with-pcidsk=internal \
              --with-jpeg='/usr/include' --with-charls \
              --with-jpeg12 \
              --with-gif='/usr/include' \
              --with-ogdi=no \
              --with-fme=no \
              --with-sosi=no \
              --with-mongocxx=no \
              --with-hdf4='/opt/hdf4' \
              --with-kea=yes \
              --with-jasper='/usr/include/jasper' \
              --with-fgdb=no \
              --with-ecw=yes \
              --with-kakadu=no \
              --with-mrsid=no --with-jp2mrsid=no --with-mrsid_lidar=no \
              --with-msg=no \
              --with-bsb \
              --without-oci \
              --with-grib \
              --with-gnm \
              --with-mysql='/usr/bin/mysql_config' \
              --with-ingres=no \
              --with-xerces=yes \
              --with-expat=yes \
              --with-libkml=no \
              --with-odbc='/usr/include/' \
              --with-dods-root=no \
              --with-xml2='/usr/bin/xml2-config' \
              --with-rasterlite2=yes \
              --with-pcre \
              --without-teigha --with-teigha-plt \
              --with-idb \
              --without-sde \
              --with-epsilon=no \
              --with-webp='/usr/include/webp' \
              --with-sfcgal=no \
              --with-qhull='/usr/include' \
              --with-opencl \
              --with-freexl=yes \
              --with-libjson-c=internal \
              --with-pam \
              --with-podofo=yes \
              --with-pdfium=no \
              --with-proj --with-proj5-api=yes \
              --with-perl \
              --without-php \
              --with-python \
              --with-java=no \
              --without-mdb \
              --without-rasdaman \
              --with-armadillo=yes \
              --with-cryptopp=yes \
              --with-crypto=yes \
              --with-mrf \
              --without-null 2>&1 | tee configure.log

    The output of this configure step (combined stdout and stderr) is attached as configure.log. Additionally, ./configure createad a config.log. It is also attached.

  6. Trying to compile: make will eventually fail. Errorneous terminal output from frmts/openjpeg I have given above. configure.log config.log
rouault commented 5 years ago

I believe that the plugins building only works if you ./configure --without-libtool

dreirund commented 5 years ago

Yes, --without-libtool is the option that works. Thanks for mentioning & maybe this should be included in configure's --help, if not already done in up-to-date version? How could one guess?