[gdal-dev] Issue building static only on OSX resolved in 2.2.0RC1

Roger Bivand Roger.Bivand at nhh.no
Thu May 4 01:25:36 PDT 2017


Hi,

The R-core member working hard to keep up with OSX found issues building 
GDAL static for the rgdal and sf R packages with GDAL 2.1.3 on El Capitan, 
but reports success with GDAL 2.2.0RC1. I can't see the relevant line in 
the NEWS file in 2.2.0RC1, so I'm posting this to keep his experiences on 
the record - probably only a few downstream users need to build strictly 
static.

Roger

The report:

"Two issues with --disable-shared --enable-static --with-pic that I 
recall:

1) the default build fails due to an issue in the libtool linking
2) I got it to build by using --without-libtool
3) despite --disable-shared the result builds shared libgdal and links all
binaries against it (moreover the id path in the dylib is wrong)

so I don't have a fix, I have simply manually created libgdal.a, removed 
.dylib so it won't be used and re-pointed the binaries into a versioned 
path that is not used during linking phases. That'll all just a hack, it 
doesn't "fix" it in the sources.

The details for 2.1.3:

if you want to raise this with GDAL -- the details:

## "regular" build
configure --with-pic --disable-shared --enable-static
--with-static-proj4=/usr/local/lib/libproj.a --with-liblzma

fails with

/Applications/Xcode.app/Contents/Developer/usr/bin/make libgdal.la
/bin/sh /Builds/unix/recipes/build/gdal-2.1.3-obj/libtool --mode=link
clang++    -L/usr/local/lib/libproj.a/lib -lproj  -lsqlite3 -lexpat
-L/usr/local/lib -lnetcdf -lhdf5_hl -lhdf5 -ldl -lm -lz -lcurl -lhdf5 
-ljpeg
-lpng -llzma -lz -lpthread -ldl  -lpcre   -lcurl           -liconv  -lxml2
-lz -lpthread -licucore -lm    -o libgdal.la
/Builds/unix/recipes/build/gdal-2.1.3-obj/frmts/o/*.lo
/Builds/unix/recipes/build/gdal-2.1.3-obj/gcore/*.lo
/Builds/unix/recipes/build/gdal-2.1.3-obj/port/*.lo
/Builds/unix/recipes/build/gdal-2.1.3-obj/alg/*.lo
/Builds/unix/recipes/build/gdal-2.1.3-obj/apps/commonutils.lo
/Builds/unix/recipes/build/gdal-2.1.3-obj/apps/gdalinfo_lib.lo
/Builds/unix/recipes/build/gdal-2.1.3-obj/apps/gdal_translate_lib.lo
/Builds/unix/recipes/build/gdal-2.1.3-obj/apps/gdalwarp_lib.lo
/Builds/unix/recipes/build/gdal-2.1.3-obj/apps/ogr2ogr_lib.lo
/Builds/unix/recipes/build/gdal-2.1.3-obj/apps/gdaldem_lib.lo
/Builds/unix/recipes/build/gdal-2.1.3-obj/apps/nearblack_lib.lo
/Builds/unix/recipes/build/gdal-2.1.3-obj/apps/gdal_grid_lib.lo
/Builds/unix/recipes/build/gdal-2.1.3-obj/apps/gdal_rasterize_lib.lo
/Builds/unix/recipes/build/gdal-2.1.3-obj/apps/gdalbuildvrt_lib.lo
/Builds/unix/recipes/build/gdal-2.1.3-obj/ogr/ogrsf_frmts/o/*.lo
./ogr/ogrgeometryfactory.lo ./ogr/ogrpoint.lo ./ogr/ogrcurve.lo
./ogr/ogrlinestring.lo ./ogr/ogrlinearring.lo ./ogr/ogrpolygon.lo
./ogr/ogrutils.lo ./ogr/ogrgeometry.lo ./ogr/ogrgeometrycollection.lo
./ogr/ogrmultipolygon.lo ./ogr/ogrsurface.lo ./ogr/ogrmultipoint.lo
./ogr/ogrmultilinestring.lo ./ogr/ogrcircularstring.lo
./ogr/ogrcompoundcurve.lo ./ogr/ogrcurvepolygon.lo
./ogr/ogrcurvecollection.lo ./ogr/ogrmulticurve.lo 
./ogr/ogrmultisurface.lo
./ogr/ogr_api.lo ./ogr/ogrfeature.lo ./ogr/ogrfeaturedefn.lo
./ogr/ogrfeaturequery.lo ./ogr/ogrfeaturestyle.lo ./ogr/ogrfielddefn.lo
./ogr/ogrspatialreference.lo ./ogr/ogr_srsnode.lo ./ogr/ogr_srs_proj4.lo
./ogr/ogr_fromepsg.lo ./ogr/ogrct.lo ./ogr/ogr_opt.lo 
./ogr/ogr_srs_esri.lo
./ogr/ogr_srs_pci.lo ./ogr/ogr_srs_usgs.lo ./ogr/ogr_srs_dict.lo
./ogr/ogr_srs_panorama.lo ./ogr/ogr_srs_ozi.lo ./ogr/ogr_srs_erm.lo
./ogr/swq.lo ./ogr/swq_expr_node.lo ./ogr/swq_parser.lo 
./ogr/swq_select.lo
./ogr/swq_op_registrar.lo ./ogr/swq_op_general.lo 
./ogr/ogr_srs_validate.lo
./ogr/ogr_srs_xml.lo ./ogr/ograssemblepolygon.lo ./ogr/ogr2gmlgeometry.lo
./ogr/gml2ogrgeometry.lo ./ogr/ogr_expat.lo ./ogr/ogrpgeogeometry.lo
./ogr/ogrgeomediageometry.lo ./ogr/ogr_geocoding.lo ./ogr/osr_cs_wkt.lo
./ogr/osr_cs_wkt_parser.lo ./ogr/ogrgeomfielddefn.lo ./ogr/ograpispy.lo \
             -rpath /usr/local/lib \
             -no-undefined \
             -version-info 21:3:1
libtool: link:
`/Builds/unix/recipes/build/gdal-2.1.3-obj/frmts/o/BitMask.lo' is not a
valid libtool object
make[2]: *** [libgdal.la] Error 1
make[1]: *** [check-lib] Error 2
make: *** [gdal-2.1.3-dst] Error 2

$ file /Builds/unix/recipes/build/gdal-2.1.3-obj/frmts/o/BitMask.lo
/Builds/unix/recipes/build/gdal-2.1.3-obj/frmts/o/BitMask.lo: Mach-O 
64-bit
object x86_64


##
configure --with-pic --disable-shared --enable-static
--with-static-proj4=/usr/local/lib/libproj.a --with-liblzma
--without-libtool

still creates a dylib and links all binaries against it:

clang++ -dynamiclib  ... -o
/Builds/unix/recipes/build/gdal-2.1.3-obj/libgdal.dylib

$ otool -L gdal-2.1.3-dst/usr/local/bin/gdal_grid
gdal-2.1.3-dst/usr/local/bin/gdal_grid:
         /Builds/unix/recipes/build/gdal-2.1.3-obj/libgdal.dylib
(compatibility version 0.0.0, current version 0.0.0)
         /usr/lib/libsqlite3.dylib (compatibility version 9.0.0, current
version 216.4.0)

and anyway the ID is invalid (it's the build location, not the target)."



-- 
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: Roger.Bivand at nhh.no
Editor-in-Chief of The R Journal, https://journal.r-project.org/index.html
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en


More information about the gdal-dev mailing list