[Freeswitch-users] configure fails to find libpq

Claus Andersen clan at wheel.dk
Fri Jun 14 12:35:12 MSD 2013


On Thu, 13 Jun 2013, Steven Ayre wrote:

> To answer your question of what the test is doing, it'll take the required flags/libs from pg_config (which it
> looks like it found) and then try compiling a tiny program linking to it to check if the library exists and when
> testing functions if that function is exported by that version of the library. Any compile error means 'no'.
> That ac_ variable is checking if its 'set' which'd mean the test passed. Config.log will show all the tests
> being run and any error output for them.
> -Steve

Thank you very much. Most helpful!

I had only tail'ed config.log and further up I found:

configure:19550: checking for PostgreSQL libraries
configure:19584: checking for PQgetvalue in -lpq
configure:19619: gcc -o conftest -g -O2   conftest.c -lpq  -lodbc  >&5
/usr/bin/ld: cannot find -lpq
collect2: ld returned 1 exit status
configure:19626: $? = 1

So the linker is not able to find and include the library. The empty 
spaces after -O2 and -lpq might indicate that some empty variables might 
have been inserted.

>From configure I know that we can find pg_config:

checking for pg_config... /usr/pgsql-9.2/bin/pg_config
checking for PostgreSQL libraries... checking for PQgetvalue in -lpq... no
configure: error: no usable libpq; please install PostgreSQL devel package 
or equivalent

And from the shell I know I get the proper path:
$ pg_config --libdir
/usr/pgsql-9.2/lib

And from the configure script it looks like the correct parameter is used:
POSTGRESQL_LDFLAGS="`$PG_CONFIG --ldflags` -L`$PG_CONFIG --libdir` -lpq"

It looks like these flags are not passed to gcc/ld when linking conftest.c

My conclusion is then that pg_config is found and the correct options and 
path are extracted but they are not used (ignored?) during testing. Or if 
they should be used - something even more serious is wrong.

If that conclusion is correct I will file a Jira. The fix should be 
trivial for people in the know. I cannot determine whether the libdir 
should be added during the test. Or if pg_config should be ignored 
completely and replaced with a simple -with-pgsql-lib=dir.

If I set LDFLAGS before I do a configure it works:
$ LDFLAGS="${LDFLAGS} -L/usr/pgsql-9.2/lib"
$ export LDFLAGS
$./configure --enable-core-pgsql-support

Configure then runs smoothly. Make does however fail but that is another 
issue I'll put in a seperate thread.

With LDFLAGS set the relevant part of config.log now looks like this:
configure:19604: checking for PQgetvalue in -lpq
configure:19639: gcc -o conftest -g -O2   -L/usr/pgsql-9.2/lib conftest.c 
-lpq  -lodbc  >&5
configure:19646: $? = 0
configure:19667: result: yes

Do you agree that this is a "proper" issue?

Kind Regards,
Claus Andersen


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list