[postgis-users] Making shp2pgsql using iconv in /usr/local?

strk at refractions.net strk at refractions.net
Thu Dec 1 03:34:24 PST 2005


On Thu, Dec 01, 2005 at 06:29:27AM -0500, Mike Leahy wrote:
> Good morning.
> 
> cvs branch 'pgis_1_0' compiled fine for me using the flags as you indicated:
> 
>   ICONV_CFLAGS="-DLIBICONV_PLUG" make
> 
> I figure you're right about LIBICONV_PLUG forcing the use of glibc 
> instead of libiconv.  If it is defined, the lines that look like
> 
>   "#define iconv* libiconv*"
> 
> are all skipped in iconv.h, and shp2pgsql compiles nicely.  Presumably 
> those define statements would be needed in the absence of glibc.

In the absence of glibc ICONV_LDFLAGS would also be needed.
Larry, can you check you can have your requirements met with the
version in pgis_1_0 CVS ? You can set ICONV_LDFLAGS and ICONV_CFLAGS
in Makefile.config as well (no need to use environment).

--strk;

> 
> Mike
> 
> strk at refractions.net wrote:
> >On Wed, Nov 30, 2005 at 10:01:39PM -0500, Mike Leahy wrote:
> >>Hello again,
> >>
> >>On second thought, a cleaner solution to this is to add "#define 
> >>LIBICONV_PLUG" just before the line with "#include <iconv.h>" in 
> >>shp2pgsql.c.  This essentially accomplishes the same (i.e., avoids 
> >>redefinition of the libiconv_* functions), and without hacking-up the 
> >>iconv.h like I did in my previous.  I tried to do this via the make 
> >>command like so:
> >>
> >> CFLAGS="-DLIBICONV_PLUG" make
> >>
> >>as well as
> >>
> >> CFLAGS="-DLIBICONV_PLUG" make loaderdumper
> >>
> >>but that had no effect (is this right the right way?).  I think part of 
> >>the issue here is that CFLAGS is reset at the start of loader/Makefile, 
> >>so any CFLAGS (or LDFLAGS) options that are supplied when executing make 
> >>are wiped by the time the loader source is compiled.
> >
> >Setting CFLAGS in the environment works fine with postgis-head.
> >The CFLAGS reset happens in PGSQL_SRC/Makefile.global, there's
> >no easy fix for 1.0.
> >
> >>Should LIBICONV_PLUG be an option that is just always enabled when 
> >>USE_ICONV=1, or should it be optional?  Everything worked fine when I 
> >>added "LIBICONV_PLUG = 1" in Makefile.config, then the following lines 
> >>in loader/Makefile:
> >>
> >>ifeq ($(LIBICONV_PLUG),1)
> >>	override CFLAGS += -DLIBICONV_PLUG
> >>endif
> >
> >I guess that LIBICONV_PLUG forces you to use the glibc version
> >rather then libiconv, right ? This would fail on system with
> >libiconv *only* external to libc, correct ?
> >
> >Mapserver solution was to always link against libiconv if present and let
> >header file inclusion determine which version to use.
> >
> >I've committed a patch for the 1.0 branch allowing you to specify
> >ICONV_LDFLAGS and ICONV_CFLAGS, please check if that would do for
> >you. Your choice would be:
> >
> >	ICONV_CFLAGS="-DLIBICONV_PLUG" make
> >
> >Original user choice would be something like:
> >
> >	ICONV_CFLAGS="-I/usr/local/include" \
> >		ICONV_LDFLAGS="-L/usr/local/lib -liconv" make
> >
> >Let me know if this makes it.
> >I'd reserve changes in the HEAD branch for later, to allow for
> >autodetection of cases in which external lib only supports iconv.
> >Filing a bug report would help keeping track of this.
> >Thanks.
> >
> >--strk;
> >
> >>Anyway, that's all for now.
> >>
> >>Regards,
> >>Mike
> >>
> >>
> >>
> >>
> >>Mike Leahy wrote:
> >>>Hey there,
> >>>
> >>>I think this problem might be related to a bug found with MapServer a 
> >>>while back: http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=909
> >>>
> >>>I tried commenting out the following lines in /usr/local/include/iconv.h 
> >>>(version 1.10), and PostGIS compiled without errors:
> >>>
> >>>45: //#undef iconv_t
> >>>46: //#define iconv_t libiconv_t
> >>>
> >>>70: //#define iconv_open libiconv_open
> >>>
> >>>80: //#define iconv libiconv
> >>>
> >>>86: //#define iconv_close libiconv_close
> >>>
> >>>96: //#define iconvctl libiconvctl
> >>>
> >>>119: //#define iconvlist libiconvlist
> >>>
> >>>
> >>>I have no idea if this breaks anything...I just figured it was related 
> >>>to conflicting libraries as suggested in the MapServer bug referenced 
> >>>above.
> >>>
> >>>I'm running FC4, with the most recent upgrades.
> >>>
> >>>I hope this helps.
> >>>
> >>>Mike
> >>>
> >>>Larry Shaffer wrote:
> >>>>strk,
> >>>>
> >>>>Sorry for the lack of info on my part. I'd like to get this working, but
> >>>>it's no big thing until I get ready to install the upcoming PostGIS 
> >>>>1.0.6
> >>>>version, as this is a brand new setup (PostgreSQL and all) with no real
> >>>>data installed into yet.
> >>>>
> >>>>Make for PostGIS works fine with USE_ICONV ?= 0
> >>>>
> >>>>
> >>>>
> >>>>My src path is /usr/local/src/postgresql-8.1.0/contrib/postgis
> >>>>
> >>>>These are the values in the PGISSRC/Makefile.config:
> >>>>
> >>>>USE_PROJ ?= 1
> >>>>PROJ_DIR ?= /usr/local
> >>>>
> >>>>USE_GEOS ?= 1
> >>>>GEOS_DIR ?= /usr/local
> >>>>
> >>>>USE_JTS ?= 0
> >>>>JTS_INCLUDES = /usr/local/include
> >>>>JTS_LIBDIR = /usr/local/lib
> >>>>
> >>>>USE_STATS=1
> >>>>
> >>>>AUTOCACHE_BBOX ?= 1
> >>>>
> >>>>PGSQL_SRC=/usr/local/src/postgresql-8.1.0
> >>>>
> >>>>USE_ICONV ?= 1
> >>>>(set to 0 for PostGIS make, then to 1 for shp2pgsql make)
> >>>>
> >>>>LPATH=/usr/local/src/postgresql-8.1.0/contrib/postgis
> >>>>
> >>>>
> >>>>
> >>>>What's in /usr/local/lib
> >>>>libiconv_plug.so
> >>>>libiconv.la
> >>>>libiconv.so
> >>>>libiconv.so.2
> >>>>libiconv.so.2.2.0
> >>>>
> >>>>What's in /usr/local/include
> >>>>iconv.h
> >>>>
> >>>>and whereis?
> >>>>
> >>>>sh-2.05a# whereis libiconv
> >>>>libiconv: /usr/local/lib/libiconv.so /usr/local/lib/libiconv.la
> >>>>sh-2.05a# whereis iconv
> >>>>iconv: /usr/bin/iconv /usr/local/bin/iconv /usr/include/iconv.h /usr/
> >>>>share/man/man1/iconv.1.gz /usr/share/man/man3/iconv.3.gz
> >>>>
> >>>>(Where is /usr/local/include/iconv.h? It *does* exist in /usr/local/
> >>>>include. This could be the problem...)
> >>>>
> >>>>Running  iconv -l  for /usr and /usr/local provides positive results of
> >>>>listing encodings (i.e. both are working).
> >>>>
> >>>>sh-2.05a# /usr/bin/iconv --version
> >>>>iconv (GNU libc) 2.2.5
> >>>>Copyright (C) 2002 Free Software Foundation, Inc.
> >>>>....
> >>>>Written by Ulrich Drepper.
> >>>>
> >>>>sh-2.05a# /usr/local/bin/iconv --version
> >>>>iconv (GNU libiconv 1.9)
> >>>>Copyright (C) 2000-2002 Free Software Foundation, Inc.
> >>>>....
> >>>>Written by Bruno Haible.
> >>>>
> >>>>I installed the libiconv-1.9.1 from GNU since it was a standalone.
> >>>>
> >>>>
> >>>>Should I install the Standard C library (glibc-2.3.2) in /usr/local ? I
> >>>>don't think the /usr/local extras before make command of shp2pgsql are
> >>>>making a difference, so I don't think it's worth the effort right now.
> >>>>See the following...
> >>>>
> >>>>
> >>>>Here's the output from the /usr/local extras
> >>>>(run from within contrib/postgis/loader)
> >>>>
> >>>>sh-2.05a# LDFLAGS="-L/usr/local/lib -liconv" CFLAGS="-I/usr/local/
> >>>>include" make shp2pgsql
> >>>>make: `shp2pgsql' is up to date.
> >>>>sh-2.05a# make clean
> >>>>rm -f shpopen.o dbfopen.o getopt.o PQunescapeBytea.o shp2pgsql.o
> >>>>pgsql2shp.o shp2pgsql pgsql2shp
> >>>>sh-2.05a# LDFLAGS="-L/usr/local/lib -liconv" CFLAGS="-I/usr/local/
> >>>>include" make shp2pgsql
> >>>>gcc -g -Wall -I.. -I. -I/usr/local/src/postgresql-8.1.0/src/interfaces/
> >>>>libpq -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Winline -fno-
> >>>>strict-aliasing -DUSE_ICONV -DFRONTEND -DSYSCONFDIR='"/usr/local/pgsql/
> >>>>etc"' -DUSE_VERSION=81 -I/usr/local/src/postgresql-8.1.0/src/include -
> >>>>D_GNU_SOURCE  -I/usr/local  -c -o shpopen.o shpopen.c
> >>>>shpopen.c:176: warning: `rcsid' defined but not used
> >>>>gcc -g -Wall -I.. -I. -I/usr/local/src/postgresql-8.1.0/src/interfaces/
> >>>>libpq -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Winline -fno-
> >>>>strict-aliasing -DUSE_ICONV -DFRONTEND -DSYSCONFDIR='"/usr/local/pgsql/
> >>>>etc"' -DUSE_VERSION=81 -I/usr/local/src/postgresql-8.1.0/src/include -
> >>>>D_GNU_SOURCE  -I/usr/local  -c -o dbfopen.o dbfopen.c
> >>>>dbfopen.c:200: warning: `rcsid' defined but not used
> >>>>gcc -g -Wall -I.. -I. -I/usr/local/src/postgresql-8.1.0/src/interfaces/
> >>>>libpq -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Winline -fno-
> >>>>strict-aliasing -DUSE_ICONV -DFRONTEND -DSYSCONFDIR='"/usr/local/pgsql/
> >>>>etc"' -DUSE_VERSION=81 -I/usr/local/src/postgresql-8.1.0/src/include -
> >>>>D_GNU_SOURCE  -I/usr/local  -c -o getopt.o getopt.c
> >>>>gcc -g -Wall -I.. -I. -I/usr/local/src/postgresql-8.1.0/src/interfaces/
> >>>>libpq -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Winline -fno-
> >>>>strict-aliasing -DUSE_ICONV -DFRONTEND -DSYSCONFDIR='"/usr/local/pgsql/
> >>>>etc"' -DUSE_VERSION=81 -I/usr/local/src/postgresql-8.1.0/src/include -
> >>>>D_GNU_SOURCE  -I/usr/local  -c -o PQunescapeBytea.o PQunescapeBytea.c
> >>>>gcc -g -Wall -I.. -I. -I/usr/local/src/postgresql-8.1.0/src/interfaces/
> >>>>libpq -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Winline -fno-
> >>>>strict-aliasing -DUSE_ICONV -DFRONTEND -DSYSCONFDIR='"/usr/local/pgsql/
> >>>>etc"' -DUSE_VERSION=81 -I/usr/local/src/postgresql-8.1.0/src/include -
> >>>>D_GNU_SOURCE  -I/usr/local  -c -o shp2pgsql.o shp2pgsql.c
> >>>>gcc -g -Wall -I.. -I. -I/usr/local/src/postgresql-8.1.0/src/interfaces/
> >>>>libpq -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Winline -fno-
> >>>>strict-aliasing -DUSE_ICONV -DFRONTEND -DSYSCONFDIR='"/usr/local/pgsql/
> >>>>etc"' -DUSE_VERSION=81 shpopen.o dbfopen.o getopt.o PQunescapeBytea.o
> >>>>shp2pgsql.o -L/usr/local/src/postgresql-8.1.0/src/port -lstdc++  -L/usr/
> >>>>local -Wl,-rpath,/usr/local/pgsql/lib -o shp2pgsql shp2pgsql.o: In 
> >>>>function `utf8':
> >>>>/usr/local/src/postgresql-8.1.0/contrib/postgis/loader/shp2pgsql.c:1630:
> >>>>undefined reference to `libiconv_open'
> >>>>/usr/local/src/postgresql-8.1.0/contrib/postgis/loader/shp2pgsql.c:1648:
> >>>>undefined reference to `libiconv'
> >>>>/usr/local/src/postgresql-8.1.0/contrib/postgis/loader/shp2pgsql.c:1654:
> >>>>undefined reference to `libiconv_close'
> >>>>collect2: ld returned 1 exit status
> >>>>make: *** [shp2pgsql] Error 1
> >>>>
> >>>>and without the /usr/local extras... just 'make shp2pgsql'...
> >>>>
> >>>>exactly the same results.
> >>>>
> >>>>I don't think /usr/local/include/incov.h is being located. Either way,
> >>>>it's failing to make when using the base install of Debian
> >>>>
> >>>>[linus]$ uname -a
> >>>>Linux linus 2.4.28-grsec+w+fhs6b+gr0501+nfs+++p4+c4+gr6b-v6.188 #1 SMP
> >>>>Fri Jan 14 11:41:59 PST 2005 i686 unknown
> >>>>
> >>>>
> >>>>
> >>>>Any help would be appreciated. Thanx.
> >>>>
> >>>_______________________________________________
> >>>postgis-users mailing list
> >>>postgis-users at postgis.refractions.net
> >>>http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>>
> >>_______________________________________________
> >>postgis-users mailing list
> >>postgis-users at postgis.refractions.net
> >>http://postgis.refractions.net/mailman/listinfo/postgis-users
> >
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

-- 

 /"\    ASCII Ribbon Campaign
 \ /    Respect for open standards
  X     No HTML/RTF in email
 / \    No M$ Word docs in email




More information about the postgis-users mailing list