Received: from redbox.venux.net (redbox.venux.net [216.47.238.10]) by hub.org (8.9.2/8.9.1) with ESMTP id NAA71292 for ; Fri, 5 Feb 1999 13:41:22 -0500 (EST) (envelope-from matthew@venux.net) Received: from thunder (net177138.hcv.com [209.153.177.138]) by redbox.venux.net (Postfix) with SMTP id 09E3C2E209; Fri, 5 Feb 1999 13:42:17 -0500 (EST) Message-Id: <4.1.19990205134100.00949550@mail.venux.net> X-Sender: mhagerty@mail.venux.net X-Mailer: QUALCOMM Windows Eudora Pro Version 4.1 Date: Fri, 05 Feb 1999 13:42:43 -0500 To: Tom Lane From: Matthew Hagerty Subject: Re: [INTERFACES] Using libpq without LD_LIBRARY_PATH Cc: pgsql-interfaces@postgreSQL.org In-Reply-To: <18287.918239304@sss.pgh.pa.us> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sorry, I forgot to specify versions, etc. PostgreSQL-6.4.2 FreeBSD-3.0-Stable gcc-2.7.2.1 Matthew At 01:28 PM 2/5/99 -0500, Tom Lane wrote: >Matthew Hagerty writes: >> I am trying to get a simple C program to compile and run without having to >> define the LD_LIBRARY_PATH environment variable. > >On what platform? Unix shared-library support is so variable across >different systems that it's hard to give any generic advice. > >> With LD_LIBRARY_PATH defined the program runs fine, without LD_LIBRARY_PATH >> defined I get this error: >> ld.so failed: Can't find shared library "libpq.so.2.0" > >Yup, not surprising. Your platform might have another way to inform the >dynamic linker where to find shared libraries besides LD_LIBRARY_PATH; >for example, if you have ldconfig then you probably want to add >/usr/local/pgsql/lib to its config file. > >> So, I added -lcrypt to the whole mess, like this: >> gcc -o test -I/usr/local/pgsql/include -lcrypt test.c >> /usr/local/pgsql/lib/libpq.a >> Then I get the following warning: >> ld: symbol __GLOBAL_OFFSET_TABLE_ remains undefined > >I'd expect that you need to put -lcrypt *after* the reference to >libpq.a, although that error message isn't exactly helpful. > >> As a last ditch effort I added symbolic links in my /usr/local/lib >> directory to libpq.a, libpq.so and libpq.so.2, and compiled like this: > >> gcc -o test -I/usr/local/pgsql/include -lpq test.c > >That'll probably link to the shared-library version of libpq, since >that's usually the default choice on systems that have shared libraries. >Dunno about the weird version-number warning; possibly the linker is >expecting to find "libpq.so.2.0" not "libpq.so.2". > > regards, tom lane