Figured it out. I believe that the PostGIS makefiles need to be changed for
Lion Server. There is a workaround but I am unable to provide a more
appropriate patch.
System description:
* OS X Server 10.7.1 (Lion) running in 64-bit mode
* XCode 4.2 (4D177b) which includes GCC version
'i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1'
* PostgreSQL 9.0.4 as built by Apple
Problem:
Following the normal steps
cd postgis-1.5.3
./configure
make
compilation succedes but the link fails.
ld: warning: ignoring file ../liblwgeom/liblwgeom.a, file was built for
archive which is not the architecture being linked (i386)
Looking back at the output, you will notice that the arguments used for
compilation of postgis specify two architectures: "gcc -arch x86_64 -arch i386
…"
The problem is that the provided version of Postgres expects PostGIS to be a
hybrid 32/64 bit library. To understand why this is occurring, we must follow
the convoluted chain of makefiles. Starting at the top, the 'make' command
invokes the 'Makefile' which on this platform triggers several commands
including a 'gnumake -f GNUmakefile postgis'. This in turn invokes the
'postgis/Makefile' which includes the build infrastructure for Postgres
extensions (/usr/lib/postgresql/pgxs/src/makefiles/pgxs.mk) that brings in
'/usr/lib/postgresql/pgxs/src/Makefile.global'. Doing this ensures that
PostGIS is built using the same compiler settings as PostgreSQL. Apple builds
Postgres as a universal binary, a hybrid of 32 and 64 bit, and they expect all
extensions to do likewise.
Workaround:
sudo cp /usr/lib/postgresql/pgxs/src/Makefile.global
/usr/lib/postgresql/pgxs/src/Makefile.global.orig
sudo vi /usr/lib/postgresql/pgxs/src/Makefile.global
# remove either '-arch i386' or '-arch x86_64' from the CFLAGS and LDFLAGS
definitions as appropriate, e.g. remove i386 for 64 bit platforms.
Better Solution:
Rejigger the PostGIS makefile to build a hybrid library.
For the dependencies, this is straightforward. Here are the steps for Proj.4:
cd proj-4.7.0
./configure
make
sudo make install
setenv LDFLAGS="-arch i386 -m32"
setenv CFLAGS="-arch i386 -m32"
setenv CXXFLAGS="-arch i386 -m32"
./configure --host=i386-apple-darwin11.1.0
make clean
make
lipo create src/.libs/libproj.0.6.6.dylib
/usr/local/lib/libproj.0.6.6.dylib -output libproj.0.6.6.dylib
sudo mv libproj.0.6.6.dylib /usr/local/lib/libproj.0.6.6.dylib
sudo chown root /usr/local/lib/libproj.0.6.6.dylib
unsetenv LDFLAGS
unsetenv CFLAGS
unsetenv CXXFLAGS
The steps for GEOS are similar.
Similar steps work for PostGIS. These can be done manually but I'm not sure
how to automate them with the current make environment.
On Sep 14, 2011, at 11:16 AM, Jerry Carter wrote:
>
> I'm trying to compile PostGIS 1.5.3 and getting tripped up with 32 vs. 64
> bit. Following the normal process,
>
> cd postgis-1.5.3
> ./configure
> make
>
> compilation proceeds but the link fails.
>
> ld: warning: ignoring file ../liblwgeom/liblwgeom.a, file was built for
> archive which is not the architecture being linked (i386)
>
> On the linking step, I noticed that the architecture flags specify both 32
> and 64 bit, i.e. "-arch x86_64 -arch i386", but can't figure out how to
> disable 32 bit. I've already rebuilt Proj.4 4.7.0 and GEOS 3.2.2 as hybrid
> 32+64 bit libraries.
>
> Any suggestions to either disable 32-bit entirely for PostGIS or to get the
> makefiles to build liblwgeom as a hybrid? Thanks much.
>
> -=- Jerry
>
> P.S. I am using GCC version 'i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1'
> which is shipped with Xcode 4.2.
_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users