Re: /usr/bin/ld: cannot find -lpq

From: Tena Sakai <tsakai(at)gallo(dot)ucsf(dot)edu>
To: Yon Lew <lewyon(at)gmail(dot)com>, "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: /usr/bin/ld: cannot find -lpq
Date: 2009-12-04 06:23:56
Message-ID: C73DEAFC.9163%tsakai@gallo.ucsf.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi Lew,

Thanks for your response. But I am more confused...

When I ran "ldd /usr/local/bin/pivot" on the machine I have
successfully compiled pivot.c, it returns:
libpq.so.5 => /usr/local/pgsql/lib/libpq.so.5 (0x0000002a95557000)
libc.so.6 => /lib64/tls/libc.so.6 (0x0000003b0dc00000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x0000003b12f00000)
/lib64/ld-linux-x86-64.so.2 (0x0000003b0da00000)
I check LD_LIBRARY_PATH variable on the centOS machine
(where I am trying to compile now), it returns:
LD_LIBRARY_PATH=/lib:/opt/gridengine/lib/lx26-x86:/state/partition1/apps/pgsql/lib:/usr/local/lib:/opt/gridengine/lib/lx26-x86
and I find libpq.so, libpq.so.5, and libpq.so.5.1 in /state/partition1/apps/pgsql/lib
directory; libc.so.6 and libcrypt.so.1 both in /lib. Finally, the last one,
/lib64/ld-linux-x86-64.so.2 is a symbolic link to /lib64/ld-2.3.4.so (on
Redhat 64-bit machine). There is no such thing as ld-linux-x86-64.so.2
on centOS machine. However, there is /lib/ ld-linux.so.2 which is a
symbolic link to /lib/ld-2.5.so.

I don't really know what this means with respect to the error message:
/usr/bin/ld: cannot find -lpq
collect2: ld returned 1 exit status
Is there any way to extrapolate something a bit more relavant, I wonder.

Regards,

Tena Sakai
tsakai(at)gallo(dot)ucsf(dot)edu

On 12/3/09 8:26 PM, "Yon Lew" <lewyon(at)gmail(dot)com> wrote:

Just a guess, but it sounds to me like a problem with $LD_LIBRARY_PATH.

Try running the ldd command to list your dependencies:

> ldd /bin/ls

librt.so.1 => /lib64/librt.so.1 (0x00002b40a142b000)
libacl.so.1 => /lib64/libacl.so.1 (0x00002b40a1534000)
libc.so.6 => /lib64/libc.so.6 (0x00002b40a163b000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00002b40a187c000)
/lib64/ld-linux-x86-64.so.2 (0x00002b40a130f000)
libattr.so.1 => /lib64/libattr.so.1 (0x00002b40a1995000)

If you come up with unmatched dependencies try adding the path containing the .so file, or its symbolic link, to your $LD_LIBRARY_PATH or $LD_LIBRARY_PATH_64 environment variable. When ldd comes back clean you should be good to go.

On Thu, Dec 3, 2009 at 7:25 PM, Tena Sakai <tsakai(at)gallo(dot)ucsf(dot)edu> wrote:
Hi Everybody,

I am not sure if this is the right mailing list to ask
what I want to ask. Please direct me to the right place,
if there is a better list.

Close to a year ago, I wrote a C program using libpq package.
It took me a week to debug, but I got it compiled and I have
been using it regularly. The program is named pivot and compiled
on a Redhat linux (AMD 64-bit) machine with the command:

cc -I/pgsql/pgsql836/include -L/pgsql/pgsql836/lib -lpq -o pivot pivot.c

And I just tried recompiling it on that machine and it compiles without a
complaint. I now need to re-compile it on a Intel 32-bit machine running
centOS. When I issue the same command on the centOS machine, I get
complaint:
/usr/bin/ld: cannot find -lpq
collect2: ld returned 1 exit status

I thought that this meant that the shared library named libpq.so.bla
is missing. But to my surprise, I find libpq.so.4.1 in /usr/lib
directory. (There is also a symbolic link libpq.so.4 pointing at
libpq.so.4.1 in the same place.)

So, I don't know what the complaint is about.

Can someone please clue me in?

Thank you in advance.

Regards,

Tena Sakai
tsakai(at)gallo(dot)ucsf(dot)edu

--
Sent via pgsql-admin mailing list (pgsql-admin(at)postgresql(dot)org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Browse pgsql-admin by date

  From Date Subject
Next Message Tena Sakai 2009-12-04 07:14:27 Re: /usr/bin/ld: cannot find -lpq
Previous Message Tom Lane 2009-12-04 06:21:34 Re: /usr/bin/ld: cannot find -lpq