Opened 14 years ago

#3347 new defect

Mapserver fails to compile when self-installed GEOS newer than system GEOS

Reported by: rpriedhorsky Owned by: dmorissette
Priority: normal Milestone:
Component: Build Problems Version: 5.6
Severity: normal Keywords:
Cc:

Description

I believe this bug boils down to an ordering problem in the link step; thus, I'm not sure it's critical to follow my recipe precisely.

Steps to reproduce:

  1. Get a Linux system where the system GEOS is version 2.2.3 and the system GDAL is compiled against that GEOS (e.g., Ubuntu Hardy with libgdal1-dev and libgeos-dev installed).
  1. Build and install GEOS 3.0.3 in /export/scratch/reid/geos
  1. Configure MapServer 5.6.1 as follows:

./configure -with-geos=/export/scratch/reid/geos/bin/geos-config --with-proj --with-agg --with-ogr --with-gdal --with-freetype --with-postgis=/usr/lib/postgresql/8.2/bin/pg_config

  1. make

The build fails in the linking step with the following error:

g++ -O2 -fPIC -Wall -DHAVE_VSNPRINTF -DNEED_STRLCAT -DNEED_STRRSTR -DUSE_WMS_SVR -DUSE_POSTGIS -DUSE_GDAL -DUSE_OGR -DUSE_GEOS -DGEOS_HAS_SIMPLIFY -DUSE_PROJ -DUSE_EPPL -DUSE_AGG -DUSE_GD_GIF -DUSE_GD_PNG -DUSE_GD_JPEG -DUSE_GD_WBMP -DUSE_GD_FT -DGD_HAS_FTEX_XSHOW -DGD_HAS_GDIMAGEGIFPTR -DGD_HAS_GETBITMAPFONTS -DUSE_ICONV -DUSE_ZLIB -I/usr/include -I/usr/include/freetype2 -I/usr/include/gdal -I/usr/include/postgresql -I/export/scratch/reid/geos/include shp2img.o -L. -lmapserver -lgd -L/usr/lib64 -lgd -ljpeg -lfreetype -lz -lpng -lz -lXpm -lX11 -ljpeg -lfreetype -lz -lpng -lz -lXpm -lX11 -lproj -ljpeg -lpng -L/usr/lib -lgdal1.4.0 -L/usr/lib -lgeos -lgeos_c -lodbc -lodbcinst -L/usr/lib -lxerces-c -lpthread -ljasper -lhdf5 -lmfhdf -ldf -logdi -lgif -ljpeg -ltiff -lpng -lnetcdf -lpq -L/usr/lib -lpq -lz -lpthread -lm -lrt -ldl -lsqlite3 -lcurl -lgssapi_krb5 -L/usr/lib/mysql -lmysqlclient -L/usr/lib -lpq -lpgport -lpam -lssl -lcrypto -lkrb5 -lcom_err -lz -lreadline -lcrypt -ldl -lm -L/export/scratch/reid/geos/lib -lgeos_c -lc -lz -lm -lstdc++ -o shp2img
./libmapserver.a(mapgeos.o): In function `msGEOSTopologyPreservingSimplify':
mapgeos.c:(.text+0x1843): undefined reference to `GEOSTopologyPreserveSimplify'
./libmapserver.a(mapgeos.o): In function `msGEOSSimplify':
mapgeos.c:(.text+0x1893): undefined reference to `GEOSSimplify'
collect2: ld returned 1 exit status
make: * [shp2img] Error 1

Note that the right path for GEOS is (-L/export/scratch/reid/geos/lib) in the command, but references to -lgeos and -lgeos_c appear before it. Copying and pasting this command and placing "-L/export/scratch/reid/geos/lib" right after "-L." leads to successful completion of the command.

Re-configuring with --without-ogr and --without-gdal didn't seem to help.

Workaround: apply the following (ugly) patch to Makefile.in and reconfigure. Then build succeeds and mapserv binary seems to be OK (tested only against PostGIS backend).

--- Makefile.in.orig    2010-02-23 15:42:26.000000000 -0600
+++ Makefile.in 2010-02-23 16:04:36.000000000 -0600
@@ -254,7 +254,8 @@
 CXXFLAGS = @CXXFLAGS@ $(FLAGS)
 
 # Link flags and shared libs only
-SUP_LIBS =  $(GD_LIB) $(AGG_LIB) $(OGL_LIB) $(FTGL_LIB) $(PDF_LIB) $(TIFF_LIB) $(PROJ_LIBS) \
+SUP_LIBS = -L/export/scratch/reid/geos/lib \
+            $(GD_LIB) $(AGG_LIB) $(OGL_LIB) $(FTGL_LIB) $(PDF_LIB) $(TIFF_LIB) $(PROJ_LIBS) \
           $(JPEG_LIB) $(PNG_LIB) $(SDE_LIB) $(GDAL_LIB) $(MING_LIB) $(POSTGIS_LIB) \
          $(MYGIS_LIB) $(CURL_LIB) $(ORACLESPATIAL_LIB) $(GEOS_LIB) \
          $(THREAD_LIB) $(ICONV_LIB) $(FASTCGI_LIB) \

I did try placing $(GEOS_LIB) before $(GDAL_LIB), but that didn't help. I assume there's some subtlety about the link step that I don't understand. Thus, I punted with a quick and dirty patch that worked for me - sorry it's not suitable as a code submission.

Change History (0)

Note: See TracTickets for help on using tickets.