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

Поиск
Список
Период
Сортировка
От Alexander Farber
Тема Re: undefined reference to `PQprepare' with postgresql-dev 7.4.7-6sarge2
Дата
Msg-id 943abd910608240800y8f9ef52od477a5156f17bcc1@mail.gmail.com
обсуждение исходный текст
Ответ на undefined reference to `PQprepare' with postgresql-dev 7.4.7-6sarge2  ("Alexander Farber" <alexander.farber@gmail.com>)
Список pgsql-general
I've also checked
http://www.postgresql.org/docs/7.4/interactive/libpq-exec.html
and PQprepare() isn't mentioned there at all.
Wasn't it provided in PostgreSQL version 7?

Is there a way to workaround it?
Maybe by using pqPrepareAsyncResult()?

And how could I #ifdef in my libpq-program, to
detect an older PostgreSQL version? The headers

   /usr/include/postgresql/libpq-fe.h and
   /usr/include/postgresql/postgres_ext.h

don't have any PG_VERSION or similar define...


On 8/24/06, Alexander Farber <alexander.farber@gmail.com> wrote:
> 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
>
> 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

В списке pgsql-general по дате отправления:

Предыдущее
От: Stefan Kaltenbrunner
Дата:
Сообщение: Re: undefined reference to `PQprepare' with postgresql-dev
Следующее
От: Tom Lane
Дата:
Сообщение: Re: undefined reference to `PQprepare' with postgresql-dev 7.4.7-6sarge2