Mac OS 10.4/10.5 compile issues

View: New views
5 Messages — Rating Filter:   Alert me  

Mac OS 10.4/10.5 compile issues

by Israel Brewster :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am developing an application that links against libpq on Mac OS  
10.5. I want this application to be able to run on both 10.4 and 10.5.  
So far I have it working fine on my 10.5 build machine. However, when  
I try moving it to a 10.4 machine, I run into problems apparently  
related to the libpq build.

My first attempt was with a "standard" universal binary build of  
postgresql (CFLAGS="-O -g -arch i386 -arch ppc" ./configure; make;  
make install ) This produced a .dylib file that my application happily  
linked against, and ran fine on 10.5. When I move the library and  
application to 10.4, however, while the application will still launch  
and run, as soon as I try to use anything from libpq, the program  
crashes with the following error:

dyld: lazy symbol binding failed: Symbol not found: _fcntl$UNIX2003
   Referenced from: /Volumes/MIS/AssetTracker/AssetTracker.app/
Contents/MacOS/../Frameworks/libpq.5.dylib
   Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: _fcntl$UNIX2003
   Referenced from: /Volumes/MIS/AssetTracker/AssetTracker.app/
Contents/MacOS/../Frameworks/libpq.5.dylib
   Expected in: /usr/lib/libSystem.B.dylib

It would appear that libpq is looking for something in the libSystem  
library that apparently exists on 10.5, but not 10.4. I figured that a  
static build of libpq should fix this problem, so I did a make  
distclean, and then re-ran the configure command with the --disable-
shared flag to generate a static-only build. Unfortunately, this  
resulted in a slew of "undefined symbol" errors when I tried to  
compile my app. It would appear that when I don't build the shared  
libraries, my app can no longer link against libpq properly. Now,  
granted, that could be an issue with my application and not postgres  
at all, but I thought I'd ask here and see if maybe there is something  
wrong with the way I am building postgres. Thanks for any help that  
can be provided.

-----------------------------------------------
Israel Brewster
Computer Support Technician
Frontier Flying Service Inc.
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------



---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@... so that your
       message can get through to the mailing list cleanly

Re: Mac OS 10.4/10.5 compile issues

by Benjamin Reed-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Feb 6, 2008 2:36 PM, Israel Brewster <israel@...> wrote:

> dyld: lazy symbol binding failed: Symbol not found: _fcntl$UNIX2003
>    Referenced from: /Volumes/MIS/AssetTracker/AssetTracker.app/
> Contents/MacOS/../Frameworks/libpq.5.dylib
>    Expected in: /usr/lib/libSystem.B.dylib

This means you linked against the 10.5 version of libSystem.

> library that apparently exists on 10.5, but not 10.4. I figured that a
> static build of libpq should fix this problem, so I did a make

There's no such thing as a fully-static build on OSX (well, not
without doing some hackery when linking).  You end up with a static
libpq, but libSystem is dynamic-only.

The way to fix this is to add "-isysroot
/Developer/SDKs/MacOSX10.4u.sdk" to your flags, to get the 10.4 SDK.

--
Benjamin Reed a.k.a. Ranger Rick
Fink, KDE, and Mac OS X development
http://www.racoonfink.com/

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Re: Mac OS 10.4/10.5 compile issues

by Israel Brewster :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Feb 6, 2008, at 11:02 AM, Benjamin Reed wrote:

> On Feb 6, 2008 2:36 PM, Israel Brewster <israel@...>  
> wrote:
>
>> dyld: lazy symbol binding failed: Symbol not found: _fcntl$UNIX2003
>>   Referenced from: /Volumes/MIS/AssetTracker/AssetTracker.app/
>> Contents/MacOS/../Frameworks/libpq.5.dylib
>>   Expected in: /usr/lib/libSystem.B.dylib
>
> This means you linked against the 10.5 version of libSystem.
>
>> library that apparently exists on 10.5, but not 10.4. I figured  
>> that a
>> static build of libpq should fix this problem, so I did a make
>
> There's no such thing as a fully-static build on OSX (well, not
> without doing some hackery when linking).  You end up with a static
> libpq, but libSystem is dynamic-only.
>
> The way to fix this is to add "-isysroot
> /Developer/SDKs/MacOSX10.4u.sdk" to your flags, to get the 10.4 SDK.

Thanks for the info, that looks like exactly what I was looking for.  
Unfortunately, when I try  CFLAGS="-O -g -arch i386 -arch ppc -
isysroot /Developer/SDKs/MacOSX10.4u.sdk" ./configure, configure fails  
with a "C  compiler cannot create executables" error. Is this a  
problem with my dev tools install or something? It should be clean, as  
I haven't messed with it, but this seems odd.

-----------------------------------------------
Israel Brewster
Computer Support Technician
Frontier Flying Service Inc.
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------
>
>
> --
> Benjamin Reed a.k.a. Ranger Rick
> Fink, KDE, and Mac OS X development
> http://www.racoonfink.com/


---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

                http://www.postgresql.org/about/donate

Re: Mac OS 10.4/10.5 compile issues

by Benjamin Reed-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Feb 6, 2008 3:50 PM, Israel Brewster <israel@...> wrote:

> Thanks for the info, that looks like exactly what I was looking for.
> Unfortunately, when I try  CFLAGS="-O -g -arch i386 -arch ppc -
> isysroot /Developer/SDKs/MacOSX10.4u.sdk" ./configure, configure fails
> with a "C  compiler cannot create executables" error. Is this a
> problem with my dev tools install or something? It should be clean, as
> I haven't messed with it, but this seems odd.

Hard to say without the config.log; it's kind of difficult to make
everything play nicely with -isysroot sometimes.  You often need to
add --disable-dependency-tracking to autotools projects, although
postgresql doesn't use the full autotools suite, so I don't know if
that's necessary.

--
Benjamin Reed a.k.a. Ranger Rick
Fink, KDE, and Mac OS X development
http://www.racoonfink.com/

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

                http://www.postgresql.org/about/donate

Re: Mac OS 10.4/10.5 compile issues

by Israel Brewster :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message




On Feb 6, 2008, at 12:42 PM, Benjamin Reed wrote:
> Hard to say without the config.log; it's kind of difficult to make
> everything play nicely with -isysroot sometimes.  You often need to
> add --disable-dependency-tracking to autotools projects, although
> postgresql doesn't use the full autotools suite, so I don't know if
> that's necessary.

Ok, got it, thanks! Turns out it was looking for crt1.10.5.o and  
dylib1.10.5.o, but all that was in the SDK usr/lib directory was  
dylib1.o and crt1.o. A couple of quick simlinks later, it built  
properly and everything appears to be working. Hopefully the  
simlinking wasn't something stupid that will come back to bite me  
later, but at least for now my app compiles properly and runs on both  
10.4 and 10.5 without crashing. Thanks for the help!

-----------------------------------------------
Israel Brewster
Computer Support Technician
Frontier Flying Service Inc.
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------
>
>
> --
> Benjamin Reed a.k.a. Ranger Rick
> Fink, KDE, and Mac OS X development
> http://www.racoonfink.com/


---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

                http://www.postgresql.org/about/donate
LightInTheBox - Buy quality products at wholesale price!