From: | "Alexander Farber" <alexander(dot)farber(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | undefined reference to `PQprepare' with postgresql-dev 7.4.7-6sarge2 |
Date: | 2006-08-24 14:53:33 |
Message-ID: | 943abd910608240753o37bddfa8r5ac4487b1cb9757a@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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);
}
......
From | Date | Subject | |
---|---|---|---|
Next Message | Stefan Kaltenbrunner | 2006-08-24 15:00:32 | Re: undefined reference to `PQprepare' with postgresql-dev |
Previous Message | Tom Lane | 2006-08-24 14:50:27 | Re: getting around 'out of memory' errors |