From: Emilio Recio <erecio@storm.jmc.tju.edu>
To: pgsql-interfaces@postgresql.org
Cc: erecio@storm.jmc.tju.edu
Cc: emrecio@netscape.net
Subject: Cannot Statically Link libpq.a
Date: Wed, 25 Sep 2002 09:26:23 -0400
Message-ID: <3D91B97F.6090002@storm.jmc.tju.edu> (raw)
(sorry if you get this twice, but the email kept getting 'deffered'
because of a bad hello or something last night)
I try to statically link the testpq.c program via:
gcc -o testpq -lpq -static testpq.c
and get the following error:
[erecio@moz postgres]$ gcc -o testpq -static -lpq testpq.c
/tmp/ccIp5I09.o: In function `exit_nicely':
/tmp/ccIp5I09.o(.text+0xd): undefined reference to `PQfinish'
/tmp/ccIp5I09.o: In function `main':
/tmp/ccIp5I09.o(.text+0x60): undefined reference to `PQsetdbLogin'
/tmp/ccIp5I09.o(.text+0x73): undefined reference to `PQstatus'
/tmp/ccIp5I09.o(.text+0xa4): undefined reference to `PQerrorMessage'
<MORE OF THE SAME>
/tmp/ccIp5I09.o(.text+0x35d): undefined reference to `PQfinish'
collect2: ld returned 1 exit status
While dynamically linking it works fine:
$ gcc -o testpq -lpq testpq.c
$ ldd testpq
libpq.so.2 => /usr/lib/libpq.so.2 (0x4002c000)
libc.so.6 => /lib/i686/libc.so.6 (0x42000000)
libssl.so.2 => /lib/libssl.so.2 (0x4003f000)
libcrypto.so.2 => /lib/libcrypto.so.2 (0x4006c000)
libkrb5.so.3 => /usr/kerberos/lib/libkrb5.so.3 (0x40130000)
libk5crypto.so.3 => /usr/kerberos/lib/libk5crypto.so.3
(0x40187000)
libcom_err.so.3 => /usr/kerberos/lib/libcom_err.so.3 (0x40197000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x4019a000)
libresolv.so.2 => /lib/libresolv.so.2 (0x401c7000)
libnsl.so.1 => /lib/libnsl.so.1 (0x401d8000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
libdl.so.2 => /lib/libdl.so.2 (0x401ed000)
libpq.a is in /usr/lib, but it's only about 93k. For the object files
that seems alot. I need to statically link the library because I am
going to be using a custom program in an embedded device where none of
the above libraries mentioned in the ldd works. All the the programs
statically link fine, except for libpq. I am using the redhat 7.3 rpms.
-Elmo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: erecio@storm.jmc.tju.edu, emrecio@netscape.net
Subject: Re: Cannot Statically Link libpq.a
In-Reply-To: <3D91B97F.6090002@storm.jmc.tju.edu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox