Opened 16 years ago
Closed 15 years ago
#2668 closed defect (fixed)
configure doesn't grab Postgres libs from pg_config
Reported by: | kyngchaos | Owned by: | aboudreault |
---|---|---|---|
Priority: | normal | Milestone: | 6.0 release |
Component: | Build Problems | Version: | 5.0 |
Severity: | normal | Keywords: | |
Cc: | dmorissette |
Description
(long-standing problem - I thought I submitted a bug report, but I could be thinking of another project)
In the PostGIS configure check, only -lpq is added for linking, with only the libdir and includedir from pg_config:
POSTGIS_LIB="-L`$PG_CONFIG --libdir` -lpq" POSTGIS_INC="-I`$PG_CONFIG --includedir`"
When libpq is linked as a shared library this is not a problem because any extra needed libs are specified in libpq. But if I use a stripped-down Postgres with only static libraries, those extra libraries must be explicitly linked, in which case POSTGIS_LIB would need to be:
POSTGIS_LIB="-L`$PG_CONFIG --libdir` -lpq `$PG_CONFIG --libs`"
I can currently get around this by setting LDFLAGS and LIBS to the --libdir and --libs values, but it would be nice to have configure do this.
Though it could be hard to reliably detect whether the static or dynamic libpq will be linked and include the extra libs only when static, and I'm not too keen on linking a bunch of extra libs when it's dynamic, so I can live with leaving it as it is.
Change History (11)
comment:1 by , 16 years ago
Priority: | low → normal |
---|---|
Severity: | minor → normal |
comment:2 by , 16 years ago
Milestone: | → 5.4 release |
---|
I thought this was a simple/safe fix, but I'm testing with Postgres V8.0.7 and it does not have the --libs argument. Which version are you using?
I'm hesitant to add this at the last minute in the 5.2 release cycle and risk breaking the build for some configs. Setting target milestone 5.4 release for now...
comment:3 by , 16 years ago
I didn't realize that --libs was so recent.
What about an extra libs for Postgres? ie, a --with-postgis-extralibs= option, which would be added to the test in configure and the linking in the makefile.
comment:4 by , 15 years ago
Cc: | added |
---|---|
Milestone: | 5.4 release → 6.0 release |
comment:5 by , 15 years ago
Are we going with that solution ? Using a "--with-postgis-extralibs" option. Should we test all libs passed to that option or we simply assume that they exist and add them to POSTGIS_LIB ?
comment:6 by , 15 years ago
Cc: | added; removed |
---|---|
Owner: | changed from | to
I don't like the --with-postgis-extralibs option because it requires special knowledge of the situation from the user. It would probably not hurt to always set
POSTGIS_LIB="-L`$PG_CONFIG --libdir` -lpq `$PG_CONFIG --libs`"
when the --libs option is available, am I wrong?
I guess what we'd need is a way to detect if --libs is available, either by checking for the error produced by --libs if it's not present, or even better, by checking the "pg_config --version" if we can find out at which version --libs was introduced.
comment:7 by , 15 years ago
I've added a simple check to verify if "--libs" is available, if so, the extra libs are added in the POSTGIS_LIB var. kyngchaos, could you test it and confirm me that solve the problem ?
comment:8 by , 15 years ago
... well, maybe not the place to be asking, but it seems my local svn trunk copy lost its svn info (I last updated in 2007 according to file dates, though it's possible a more recent checkout was lost in a HD crash a few months ago). And I can't find SVN checkout info or a daily tarball download link anywhere.
I suppose I could try dropping configure downloaded from trac into my 5.4.1 source...
comment:9 by , 15 years ago
You can checkout the trunk via: svn co https://svn.osgeo.org/mapserver/trunk/mapserver . You can also just grab the configure/configure.in from the trac source code browser.
comment:10 by , 15 years ago
Seems to work (dropped new configure into 5.4.1 source). Tested with Postgres 8.3.7. I also tested with an old 8.0 pg_config without the --libs flag and got only the basic -lpq as expected.
OK, the LIBS/LDFLAGS trick does not work. LDFLAGS and LIBS are used by configure when doing its checks, and may help some tests succeed, but neither are used in the makefile for linking. At runtime then, there will be missing symbols errors for all the libs that weren't linked in. Bummer. I guess I hack configure for now.