Re: OS X library path issues for libpq (ver 8.3)

From: "Darren Weber" <darren(dot)weber(dot)lists(at)gmail(dot)com>
To: "Dave Page" <dpage(at)pgadmin(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: OS X library path issues for libpq (ver 8.3)
Date: 2008-09-09 17:35:12
Message-ID: b808b3510809091035m2aa1be22h1823dc1fc8a1d54f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Sep 9, 2008 at 12:46 AM, Dave Page <dpage(at)pgadmin(dot)org> wrote:
> On Tue, Sep 9, 2008 at 2:02 AM, Darren Weber
> <darren(dot)weber(dot)lists(at)gmail(dot)com> wrote:
>> I'm new to using PostgreSQL on mac OS X. I used a binary installer
>> for PostgreSQL 8.3 on mac OS X 10.5, which installs into
>>
>> /Library/PostgreSQL/[version]/....
>>
>> I'm building a lot of software that links to libpq and most of the
>> builds fail or the run-time fails, because it cannot find the
>> PostgreSQL libraries by default. It seems the dynamic link loader
>> doesn't search this path by default to locate dynamic libraries, like
>> libpq.5.dylib.
>>
>> Can you fix this issue for the binary installer?
>
> Hmm, it seems this is a side-effect of not rewriting the shared
> library paths at installation time. Because the library ID is just the
> filename, the linker doesn't write the full path to the binaries you
> compile.
>
> We changed from the old behaviour after it became apparent that the
> utilities we needed to rewrite the paths are on available on machines
> with XCode installed.
>
> I would suggest doing one of the following:
>
> sudo ln -s /Library/PostgreSQL/8.3/lib/libpq.5.dylib /usr/lib/libpq.5.dylib
>
> which will put a symlink to the library in /usr/lib, where the dynamic
> loader will find it, or:
>
> export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/Library/PostgreSQL/8.3/lib"
>
> which will tell the dynamic linker to look in the PG lib directory. A
> third possible fix would be to use install_name_tool to rewrite the
> shared library path in the executable you've built.
>
> I'll look at a solution for the installer - it'll probably have to be
> the symlink unless anyone else has a better idea...
>
> --
> Dave Page
> EnterpriseDB UK: http://www.enterprisedb.com
>

I guess the symlinks from /usr/lib to /Library/PostgreSQL/lib would
have to happen for many items (and sub-directories).

I'm still new to OS X, so the whole unix/NeXT integration issue is a
black box to me. At this point, I'm leaning on unix but I'm getting
tangled up in binary installers that create some nice .app bundles.
That's great for that particular package, but I'm discovering that OS
X is confusing me when it comes to building (ie compiling) many useful
packages from source (most of them assume a unix build environment).
I'm using macports, but they decided to use /opt for all the
installations and I'm not entirely clear about how that integrates
with the OS X unix system (in some cases it seems to conflict).
Yadda, yadda, yadda....

For one thing, I've discovered that setting DYLD_LIBRARY_PATH is not a
great idea on OS X. For one, if you set it in your shell login
profiles (.bashrc, .profile, .cshrc or whatever), most applications
that are started from the 'Finder' will not see that setting (so it's
kinda useless unless you want to work from the terminal all day).
Also, some discussion forums indicate that it can screw up some
applications. From reading 'man dyld', I gather that setting this
variable is useful for testing new libraries rather than a permanent
library solution.

Today, I'm going to follow instructions here:
http://developer.apple.com/internet/opensource/postgres.html

If that doesn't work for me, I'll fall back on macports. However,
both of these solutions involve building from source and they may not
generate the .app utilities.

Best, Darren

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2008-09-09 17:57:30 Re: Various intermittent bugs/instability - how to debug?
Previous Message Holger Hoffstaette 2008-09-09 16:30:17 Re: PostgreSQL process architecture question.