Cannot Statically Link libpq.a

From: Emilio Recio <erecio(at)storm(dot)jmc(dot)tju(dot)edu>
To: pgsql-interfaces(at)postgresql(dot)org
Cc: erecio(at)storm(dot)jmc(dot)tju(dot)edu, emrecio(at)netscape(dot)net
Subject: Cannot Statically Link libpq.a
Date: 2002-09-25 13:26:23
Message-ID: 3D91B97F.6090002@storm.jmc.tju.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

(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(at)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

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Emilio Recio 2002-09-25 13:46:49 Re: Cannot Statically Link libpq.a
Previous Message Brett Schwarz 2002-09-24 16:00:38 Re: question on pgaccess installation