[Gdal-dev] Any possibility of static compile?

Curt, WE7U archer at eskimo.com
Mon Dec 4 15:30:58 EST 2006


On Mon, 4 Dec 2006, Collins, Benjamin wrote:

> Use something like
> gcc <your options> <gdal_location>/.libs/libgdal.a
> No -L or -l necessary.
>
> You could send your exact command line to the list for more help.

I don't know if I can easily explain what I'm doing.  Linux Standard
Base (LSB) requires that an application depend only on the
LSB-distributed libraries and headers.  I use the "lsbcc" compiler
(really just a front-end to GCC) to assure that I have LSB
compliance.

I compile each library via "lsbcc", then separately compile/link my
application to those new LSB-compliant libraries I just created.
The end product is a binary that is a stand-alone app except for the
LSB support which has to be in the OS already for the OS to be
LSB-compliant.  For instance, for OpenSuSE 10.0 I install the "lsb"
package, then I can install my lsb-xastir package and it runs.  This
should work across ALL Linux systems that claim to be LSB compliant.

So...  I've been statically linking each (optional) library we use
but got stumped by GDAL.  I separately have LSB-compliant versions
of libproj/shapelib/libtiff/libgeotiff (and others) linked to my app
already.  We don't depend on GDAL/OGR for those functions.  Some of
the less-used OGR map formats are what I'm still after...

If I just had some ".a" files to link to, I'd be golden.  libgdal.a
doesn't appear to have OGR functions in it, or at least the linker
gets REAL upset when I try to link to it.

FWIW I've a attached the script I use to compile GDAL under LSB to
the end of this message (It's tiny).  The important part of code for
then linking the library to my app is:

  CPPFLAGS="$CPPFLAGS -I/opt/lsb-gdal/include"
  LDFLAGS="$LDFLAGS -L/opt/lsb-gdal/lib -lgdal"
  LIBS="$LIBS -lgdal"
  AC_DEFINE(HAVE_LIBGDAL, , [Define to 1 if you have the `gdal' library (-lgdaal).])

Is there a possibility that some parts of the GDAL library compile
are ignoring the "CC" variable?

Here's the first part of the final link for my app.  The errors go
on for many pages after that:

lsbcc  -g -O2 -Wl,--no-keep-memory -L/opt/lsb/lib -L/opt/lsb/lib
-L/opt/lsb-gdal/lib -lgdal -L/opt/lsb-graphicsmagick/lib -o xastir
alert.o awk.o bulletin_gui.o color.o datum.o db.o dbfawk.o
draw_symbols.o fcc_data.o festival.o geo-find.o geocoder_gui.o gps.o
hashtable.o hashtable_itr.o hostname.o igate.o interface.o
interface_gui.o io-common.o io-mmap.o lang.o list_gui.o locate_gui.o
location.o location_gui.o main.o maps.o map_cache.o map_dos.o
map_gdal.o map_geo.o map_gnis.o map_pdb.o map_shp.o map_tif.o
map_tiger.o map_WMS.o messages.o messages_gui.o objects.o
popup_gui.o rac_data.o rotated.o rpl_malloc.o shp_ hash.o snprintf.o
sound.o track_gui.o util.o view_message_gui.o wx.o wx_gui.o
x_spider.o xa_config.o compiledate.o -Lrtree -lrtree -Lshapelib
-lshape -lXm -lXt -lX11 -lGraphicsMagick -ltiff -ljasper -ljpeg -
lpng -lz -lm -lpthread -ldb -lrt -lXm -lXt -lSM -lICE -lX11 -lcurl
-lpcre -lproj -lgeotiff -ltiff -ljpeg -lz -lproj -lgdal
Warning: forcing gdal to be linked statically
Warning: forcing rtree to be linked statically
Warning: forcing shape to be linked statically
Warning: forcing Xm to be linked statically
Warning: forcing GraphicsMagick to be linked statically
Warning: forcing tiff to be linked statically
Warning: forcing jasper to be linked statically
Warning: forcing jpeg to be linked statically
Warning: forcing png to be linked statically
Warning: forcing db to be linked statically
Warning: forcing Xm to be linked statically
Warning: forcing curl to be linked statically
Warning: forcing pcre to be linked statically
Warning: forcing proj to be linked statically
Warning: forcing geotiff to be linked statically
Warning: forcing tiff to be linked statically
Warning: forcing jpeg to be linked statically
Warning: forcing proj to be linked statically
Warning: forcing gdal to be linked statically
/opt/lsb-gdal/lib/libgdal.a(gdalallregister.o):(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
/opt/lsb-gdal/lib/libgdal.a(geotiff.o): In function `GTiffRasterBand::GTiffRasterBand(GTiffDataset*, int)': geotiff.cpp:(.text+0x36e): undefined reference to `_Unwind_Resume'
/opt/lsb-gdal/lib/libgdal.a(geotiff.o): In function `GTiffRasterBand::GTiffRasterBand(GTiffDataset*, int)': geotiff.cpp:(.text+0x6ee): undefined reference to `_Unwind_Resume'
/opt/lsb-gdal/lib/libgdal.a(geotiff.o): In function `GTiffRasterBand::SetColorTable(GDALColorTable*)': geotiff.cpp:(.text+0x9a9): undefined reference to `operator delete(void*)'
/opt/lsb-gdal/lib/libgdal.a(geotiff.o): In function `GTiffDataset::GTiffDataset()': geotiff.cpp:(.text+0xd52): undefined reference to `_Unwind_Resume'


--
Curt, WE7U.   APRS Client Comparisons: http://www.eskimo.com/~archer
"Lotto:    A tax on people who are bad at math." -- unknown
"Windows:  Microsoft's tax on computer illiterates." -- WE7U
"The world DOES revolve around me:  I picked the coordinate system!"


#!/bin/sh

# $Id: LSB-BUILD-GDAL,v 1.2 2006/12/04 19:52:08 we7u Exp $
# Copyright (C) 2006  The Xastir Group

# Compile gdal-1.3.2b2 under Linux Standard Base 3.0.  Install into
# /opt/lsb-gdal/ directory structure.

export PATH=${PATH}:/opt/lsb/bin
export LSBCC_WARN=1

# A colon-separated list of "extra" shared libraries to link with
# the application.  Each shared lib must be LSB-compliant and must
# be distributed along with the application.
#export LSBCC_SHAREDLIBS=

CC=lsbcc ./configure \
    --prefix=/opt/lsb-gdal \
    --exec_prefix=/opt/lsb-gdal \
    --enable-static
#    --without-libtool
make clean
(make 2>&1) | tee make.log
#make -n install
sudo make install




More information about the Gdal-dev mailing list