Boost logo

Boost Users :

From: Daniel Lord (daniel_at_[hidden])
Date: 2008-03-01 12:29:07


Lothar,
My terse reply was not meant to be disrespectful ( in case you took it that
way--text conversations can be misunderstood). I only posted the output in
case you already figured it out thus avoiding spamming the list with a huge
post given there don't seem many OS X developers on it so very few give a
fig about this issue. But our numbers are growing and these painful learning
experiences are becoming more common. The regime below is a quick-and-dirty
sub-optimal brute force way of achieving a universal fat32 C++ build on OS X
with Xcode 3. Once working, you can refine from there. I am no expert nor
journeyman with Xcode though I hope to be one day. This works for me so I
can focus on my application work. HTH.

ARCHITECTURE ISSUES

----
Both my systems run Leopard 10.5.2 and are i386 ( a Core Duo Macbook Pro and
a first-gen Quad core 8-way SMP Mac Pro).
My Boost build seem to produce fat32 binaries "out of the box" with no
special configuration. as the out of 'file' on the boost_filesystem libs
shows:
./static/debug/mt/libboost_filesystem-mt-d-1_34_1.a: current ar archive
./static/debug/mt/libboost_filesystem-mt-d.a: current ar archive
./static/debug/st/libboost_filesystem-d-1_34_1.a: current ar archive
./static/debug/st/libboost_filesystem-d.a: current ar archive
./static/debug/st/libboost_filesystem-gcc40-d-1_34.a: Mach-O universal
binary with 2 architectures
./static/debug/st/libboost_filesystem-gcc40-d-1_34.a (for architecture ppc):
current ar archive
./static/debug/st/libboost_filesystem-gcc40-d-1_34.a (for architecture
i386): current ar archive
./static/release/mt/libboost_filesystem-gcc40-mt-1_34.a: Mach-O universal
binary with 2 architectures
./static/release/mt/libboost_filesystem-gcc40-mt-1_34.a (for architecture
ppc): current ar archive
./static/release/mt/libboost_filesystem-gcc40-mt-1_34.a (for architecture
i386): current ar archive
IMPORTANT: notice not all the libraries are fat32 architecture--make sure
you link in fat32 binaries  (the one that the 'file' commands states are
"universal binary with 2 architectures) if you want a universal (n this case
fat32) build. You will also need to adjust your target build settings to
include the architectures you want to build for. read teh Xocde docs to
learn how to do this. I have tried  tweaking Boost to give me a fat quad
build (i386, ppc, ppc64, x86_64) yet because of the use of bjam.
If you are not having this occur, it might be that you have CFLAGS<
CXXFLAGS, and LDFLAGS set to "-arch i386" rather than "-arch i386 -arch ppc"
somewhere in your environment. It might help to set them explicitly in the
shell and export them before running Boost though Boost might override them.
Bjam is too arcane for me to try and figure out how Boost build works--I
just don't have the time avaialbe with all the other things I need to learn
more about and projects I need to work on.
PATHS
-----
At first I tried using the default install location for the Boost libraries
(/usr/local) but that was problematic with Xcode since it seemed to grab the
first libboost_filesystem binary is found and it would be of the wrong
architecture. Longer term, I am hoping that delving into the Xcode
documentation will produce a more elegant solution to this, but for now I
jsut use brute force and  copy the files I need to the project folder. If
you use source control this has the advantage of freezing the dependent
library versions for SCM archiving--few things more vexing than having a
library change versions and break your code. Specifically, I copy the
relevant files to the project root directory, the path in the Xcode
environment variable $(SRCROOT):
1)I copy all the boost includes into my project root folder. Copy the
'boost' folder inside boost_1_34_1, once you get it working you can pull out
the ones you dont need. Also you could probably put the m in a silgne
diretory hierarchy rooted somewhere below your home to avoid the copying,
but you can work that out later--I want to keep things simple now to get it
working first.
2) I copy the particular libraries I need in a folder named "lib" in
$(SRCROOT). See above in ARCHITECURES to make sure you copy the right files.
Check them iwth the 'file' command to be sure they are universal binaries of
the desired type.
3) Modify your build settings for the target (right-click on the target in
the Xcode project view and select the build tab).  lot of settings there to
tweak, but you jsut need to setHEader Search Paths and Library Search Paths
to $(SRCROOT). IMPORTNT: do not check recursive or it whacks your name sapce
and you'll get error on building like " 'snprintf' is nto a memeber of
'std'". this dorve me nearly insane when it first happened until I figured
it out. I should have RTFM'd and could have avoided the pain and anguish.
4) open the target tree to expose the build phases (click on the trainagle
next to the target) and you'll see three standard phases: Compile Sources,
Link Binary With Libraries, and Copy Files. right-click on Link Binary With
Libraries and selet add existing file and select you libraries from the file
choose dialog.
If this is a all done correctly you should get a fat32 copile fo your
application that works. At least it works for me. As I have said repeatedly,
this is a quick and dirty regime that works but is sub-optimal. Over time
I'll refine it to ake it more efficient and maintainable. But to goal here
is to get you moving with Boost and Xcode universal builds.
I am no expert but this worked for me.
HTH
Daniel Lord
1 March 2008
---
Some people building C++/Obj-C code on OS X with Xcode and have a problem
think:"I know, I'll use the Boost Libraries". Now they have two
problems--three if they needed regular expressions. ;-)
On 3/1/08, Lothar May <boost_at_[hidden]> wrote:
> Hi Daniel,
>
>  thank you very much for testing it. It's great that it works for you.
>  Could you please tell me how you built boost? It seems you are using the
>  i386 architecture. Is your boost build a universal build, i.e. will the
>  programs run on PowerPC as well?
>
>  The problem for me is that I do not have a PowerPC based system, so I
>  cannot build boost on a PowerPC and on an i386 system and copy them to a
>  universal build - instead I need to compile both on the i386 system. The
>  way I tried to do this, although as documented, seems to break the
>  exception support. Maybe we can find a way to merge the way you are
>  building boost with the additional options needed for a universal build.
>
>  Thanks again,
>
>  Lothar
>
>
>  Daniel Lord wrote:
>  > It worked fine for me:
>  >
>  > [09:46:50] daniello_at_Mercury
>  > ~/Documents/Development/Study/Xcode-Boost/BoostExceptionTest
>  > $uname -a
>  > Darwin dhcp-2op9-2op10-east-130-35-99-215.usdhcp.oraclecorp.com
>  > <http://dhcp-2op9-2op10-east-130-35-99-215.usdhcp.oraclecorp.com> 9.2.0
>  > Darwin Kernel Version 9.2.0: Tue Feb  5 16:13:22 PST 2008;
>  > root:xnu-1228.3.13~1/RELEASE_I386 i386
>  > [09:46:57] daniello_at_Mercury
>  > ~/Documents/Development/Study/Xcode-Boost/BoostExceptionTest
>  > $./BoostExceptionTest /fake
>  > This is never printed on MacOS 10.5.
>  >
>  >
>  > On 2/26/08, *Lothar May* <boost_at_[hidden]
>  > <mailto:boost_at_[hidden]>> wrote:
>  >
>  >     Hi Daniel,
>  >
>  >     compiling boost is successful on my system, too. Are boost
exceptions
>  >     caught using your build? Is your build universal?
>  >
>  >       > I missed the thread on this, but I'll help you out if I
can--just
>  >       > bring me up to speed.
>  >
>  >     Sample test code is this:
>  >
>  >     --cut here--
>  >
>  >     #include <iostream>
>  >     #include <boost/filesystem.hpp>
>  >
>  >     using namespace std;
>  >     using namespace boost::filesystem;
>  >
>  >     int
>  >     main()
>  >     {
>  >          try
>  >          {
>  >              directory_iterator i("does_not_exist");
>  >          } catch(...)
>  >          {
>  >              cout << "This is never printed on MacOS 10.5." << endl;
>  >          }
>  >          return 0;
>  >     }
>  >
>  >     --cut here--
>  >
>  >     Best regards,
>  >
>  >     Lothar
>  >
>  >
>  >     _______________________________________________
>  >     Boost-users mailing list
>  >     Boost-users_at_[hidden] <mailto:Boost-users_at_[hidden]>
>  >     http://lists.boost.org/mailman/listinfo.cgi/boost-users
>  >
>  >
>  >
>  >
>  >
>  >
------------------------------------------------------------------------
>  >
>  > _______________________________________________
>  > Boost-users mailing list
>  > Boost-users_at_[hidden]
>  > http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>  _______________________________________________
>  Boost-users mailing list
>  Boost-users_at_[hidden]
>  http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
--


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net