Search Postgresql Archives

undefined reference to `PQprepare' with postgresql-dev 7.4.7-6sarge2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I'm trying to compile a libpq program under Debian 3.1r2 with these
packages installed:

$ dpkg -l | grep postgres
ii  postgresql     7.4.7-6sarge2  object-relational SQL database management sy
ii  postgresql-cli 7.4.7-6sarge2  front-end programs for PostgreSQL
ii  postgresql-con 7.4.7-6sarge2  additional facilities for PostgreSQL
ii  postgresql-dev 7.4.7-6sarge2  development files for libpq (PostgreSQL libr
ii  postgresql-doc 7.4.7-6sarge2  documentation for the PostgreSQL database ma

That program compiles and works fine with OpenBSD
and Cygwin (I'm using PostgreSQL 8.x there though...)

On Debian it unfortunately doesn't link:

$ gcc build/pref.o build/message.o build/pgsql.o build/user.o
build/util.o build/table.o build/common.o build/array.o
build/xstring.o build/strlcpy.o build/strlcat.o build/daemon.o -o pref
-L /usr/lib -L  /usr/lib/postgresql/lib -lpq
build/pgsql.o(.text+0x15b): In function `db_prepare':
server/pgsql.c:57: undefined reference to `PQprepare'
collect2: ld returned 1 exit status

$ pg_config --version
PostgreSQL 7.4.7

$ pg_config --libdir
/usr/lib

$ objdump -x /usr/lib/libpq.a | grep -i PQprepare
00000000         *UND*  00000000 pqPrepareAsyncResult
00001974 R_386_PLT32       pqPrepareAsyncResult
00000490 g     F .text  0000007d pqPrepareAsyncResult
000012e5 R_386_PLT32       pqPrepareAsyncResult
0000130a R_386_PLT32       pqPrepareAsyncResult
00000000         *UND*  00000000 pqPrepareAsyncResult
00001841 R_386_PLT32       pqPrepareAsyncResult

There are very few hits for the "undefined reference PQprepare"
on Google (which I take a good sign :-)

Does anybody have an idea please, what could I be doing wrong?

Why doesn't objdump find PQprepare, but finds PQconnectdb?

$ objdump -x /usr/lib/libpq.a | grep -i PQconnectdb
00000000 g     F .text  00000042 PQconnectdb

Thank you
Alex

PS: And here is the code failing to link (my server/pgsql.c)
     probably nothing special:

#define DB_CONN_STR             "host=/tmp user=XXX dbname=XXX"
#define SQL_FETCH_USER          \
   "select username, user_avatar from phpbb_users where user_active = 1 " \
   "and user_id = $1 and user_password = $2 and user_id not in " \
   "(select ban_userid from phpbb_banlist where ban_userid is not null)"
......
static void
db_reconnect()
{
       PQreset(conn);

       if (PQstatus(conn) != CONNECTION_OK) {
               warn("Connection to db '%s' failed: %s",
                   DB_CONN_STR, PQerrorMessage(conn));
               sleep(RETRY_INTERVAL);
               return;
       }

       db_prepare("sql_fetch_user", SQL_FETCH_USER, 2);
}

void
db_prepare(const char *stname, const char *query, int nparams)
{
       PGresult*       res;

       res = PQprepare(conn, stname, query, nparams, NULL);
       if (PQresultStatus(res) != PGRES_COMMAND_OK) {
               PQclear(res);
               db_disconnect();
               die("Preparing statement '%s' failed: %s",
                    query, PQerrorMessage(conn));
       }

       PQclear(res);
}
......

--
http://preferans.de


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux