Thread: How can I make a two arch libpq for snow leopard?

How can I make a two arch libpq for snow leopard?

From
Jerry LeVan
Date:
Hi,

I have a i386 version of postgresql 8.4.1 created by setting
export CC="gcc -arch i386" an then doing the config, make and make
install.

In particular libpq is an i386 library.

Now I use two database 'adaptors' psycopg2 for python and pgtcl-ng for
tcl.

The python I use is from python.org (2.6.2). It is a 32 bit system.
I can compile psycopg2 with the above python and it seems to be
working ok.

If I compile psycopg2 against the Apple python (2.6.1) I need to
tell Python to run in thirty two bit mode else there will be
libpq link problems.

In order to use psycopg2 with the Apple python I then have to
tell python to run in 32 bit mode using
VERSIONER_PYTHON_PREFER_32_BIT=yes

On the other hand...

The does not appear to be a nifty switch to tell Apple's Tcl to run
in 32 bit mode.

Inorder to compile pgtcl-ng (aka pgtcl 1.7.0 ) I have to do a
32 bit compile by setting export CC="gcc -arch i386" then
doing a configure, make and install.

A standard compile trys to build a 64 bit object but fails because
libpq is only a 32 bit library.

The i386 compile "works" but tcl cannot load the resulting shared
library
with bad architecture error ( I guess it wants 64 bit).

Now I also have an ActiveState 32 bit version of tcl and compiling
pgtcl-ng
against the active state tcl gives a loadable extension.

So the question is:

How can I build a libpq.dylib that can be loaded by either 32bit or
64bit
applications?

The only thing that comes to mind is two separate build trees, one 32bit
and the other 64bit and then somehow gluing the two libpqs together...

If the above is possible what happens when a 64 bit app tries to talk to
the 32 bit server?

If the previous question is true and I have the 64 bit libpq library
loaded
and then a 32 bit app talks to the server will the 32 bit libpq
library then
also be loaded in memory?

I guess I also need to try and build a dual architecture for dblink...

Am I confused?

Thanks for any input :)

Jerry

Re: How can I make a two arch libpq for snow leopard?

From
Scott Ribe
Date:
> The only thing that comes to mind is two separate build trees, one 32bit
> and the other 64bit and then somehow gluing the two libpqs together...

Basically, probably the easiest way to proceed--man lipo to figure out how
to combine the libraries.

--
Scott Ribe
scott_ribe@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice



Re: How can I make a two arch libpq for snow leopard?

From
Jerry LeVan
Date:
On Sep 20, 2009, at 7:47 PM, Scott Ribe wrote:

>> The only thing that comes to mind is two separate build trees, one
>> 32bit
>> and the other 64bit and then somehow gluing the two libpqs
>> together...
>
> Basically, probably the easiest way to proceed--man lipo to figure
> out how
> to combine the libraries.

Yes, I found the lipo command this morning after reading the man page
for the
arch command :)

I glued together the x86_64 and i386 libpq5.2.dylibs and copied it into
the pgsql library directory and restarted the server...looks like
it is working ok...

With the fat libpq I was able build both of the database interfaces
pgtcl and psycopg2.

By default the interface libs where created as fat libraries so I
can build/run pg apps using Apple tcl 32/64 bit or Apple python 32/64
bit.
( the arch command can force Apple tcl to run in 32 bit mode).

My remaining problems are:

     1) dblink_connect cannot resolve names, I have to use IP's.

     2) My once rock solid WxPython based Postgresql browser has
        gone sideways. After a couple of selects the app vanishes
        in a puff of smoke or it hangs.

Jerry