Building fat boost libraries on OS X

Discussion and help for Compilation problems and platform portability.

Moderators: Dade, coordinators

Building fat boost libraries on OS X

Postby Karl vom Berge » Sat Feb 16, 2008 5:38 am

For those who want to compile a universal binary of Luxrender on OS X, it is necessary to have so called fat libraries for all the dependent libraries of Luxrender (boost, OpenEXR, jpeg, png, tiff, asio and FLTK). A fat library is a library that contains code for multiple architectures. For the Apple platform current architectures are: ppc (PowerPC 32 bit), ppc64 (PowerPC 64 bit), i386 (Intel 32 bit) and x86_64 (Intel 64 bit).

The boost build system currently does not have build options for making fat libraries, but there is a patch on the boost site that provides these options. I followed these steps for building fat boost libs:

1. Download and extract the latest boost sources.

2. Get the Apple Source Library patch from the boost site. I used the bbv2patch_64.txt that also adds 64 bit build options. Put this patch in the base directory of the boost sources.

3. Patch the boost build system by following shell command in the base directory of the boost sources:

Code: Select all
patch tools/build/v2/tools/darwin.jam bbv2patch_64.txt


4. Run configure in the base directory of the boost sources. The configure script will build the boost bjam make tool and creates the user-config.jam file.

Code: Select all
./configure


5. Then build the boost libraries using bjam:

Code: Select all
./tools/jam/src/bin.macosxx86/bjam toolset=darwin arch=fat sdkroot=10.4


This builds boost 32 bit fat libraries. You can also build 64 bit libraries by using fat64 in stead of fat as arch parameter.

* Wait 20m to a couple of hours depending on your architecture :-) *

6. Install your new libraries:

Code: Select all
sudo ./tools/jam/src/bin.macosxx86/bjam toolset=darwin arch=fat sdkroot=10.4 install


Its obvious you have to use the same parameters as in step 5. You can add --prefix=<your preferred location> to the above command in order to override the default installation location.


I am planning to write tutorials on building the other dependencies for lux as I go along. Final tutorial will merge all the different tutorials.

Karl
Last edited by Karl vom Berge on Sun Feb 17, 2008 12:34 pm, edited 1 time in total.
User avatar
Karl vom Berge
 
Posts: 81
Joined: Mon Jan 14, 2008 7:11 am
Location: Antwerp, Belgium

Re: Building fat boost libraries on OS X

Postby Radiance » Sat Feb 16, 2008 7:52 am

fantastic ! :)

Image

so when can we expect a fully working universal mac pkg ? :)

Radiance
User avatar
Radiance
 
Posts: 3968
Joined: Wed Sep 19, 2007 2:13 am

Re: Building fat boost libraries on OS X

Postby jim » Sat Jun 14, 2008 11:42 pm

In the few months since this was posted, things have changed. (not surprising, especially considering how much Lux has changed in that time) Here's some updated information...

1. Download the package, verify the checksum, etc. - unpack it into your build directory. Run "./configure"
2. "./tools/jam/src/bin.macosxx86/bjam --toolset=darwin --build-type=complete --with-system architecture=combined"
3. Look at your new universal binary library (.a) files. (ppc and i386)
4. Install where needed.

64-bit is still a problem. The linked patch doesn't exist any more, and even if it did the 1.35 version has changed enough to possibly make it not work anyway. But there are people who have supposedly done "4-way" universal binaries. I'm going to see if I can get in touch with someone about what they have done. (supposedly a shell script that takes care of exactly what we need) But tracking down their "real" email address is a minor challenge - http://lists.apple.com/archives/xcode-u ... 00157.html - so that probably won't happen until tomorrow.

We really need to get 64bit working. As I remember, my x86_64 build hit about 35K S/s on the mandatory/full-cornell scene. After rebuilding everything (latest openexr, boost, etc.) via MacPorts I could only get it to use i386, because of linking against i386 libs. I don't understand that, since the old libs were i386 as well, but regardless the S/s is down to about 25K. :(

Anyway, just wanted to post a quick update on this - if anyone else is working on stuff, do please let me know so we don't duplicate efforts.
jim
 
Posts: 73
Joined: Sat Nov 17, 2007 7:07 pm

Re: Building fat boost libraries on OS X

Postby jim » Mon Jun 16, 2008 11:43 pm

Good news. I obtained the build script from the gentleman who made it, and compiled some "quad" binaries of the libraries earlier this afternoon. That's PPC, PPC_64, i386, and x86_64. Bad news. Boost 64-bit libs won't build nicely under the 10.4 SDK, so these are going to be 10.5 only - at least for right now. The problems *may* only be for shared libs. Once I can determine more, I will update.
jim
 
Posts: 73
Joined: Sat Nov 17, 2007 7:07 pm

Re: Building fat boost libraries on OS X

Postby Karl vom Berge » Tue Jun 17, 2008 8:12 am

Thanks for the update jim! Does the gentleman allow sharing his piece d'oeuvre with a broader public? :mrgreen:

Karl
User avatar
Karl vom Berge
 
Posts: 81
Joined: Mon Jan 14, 2008 7:11 am
Location: Antwerp, Belgium

Re: Building fat boost libraries on OS X

Postby jim » Tue Jun 17, 2008 10:41 pm

I didn't specifically ask that - but he did post in a mailing list that anyone should contact him to get ahold of it. So I don't have any problem sharing. See the attached. I'm still working on a few other things so I can (try) building a 64-bit Mac Lux. In the next few days I should have an update.
Attachments
mkosx.zip
mkosx.sh - build multi-arch Boost libs on OSX
(2.86 KiB) Downloaded 173 times
jim
 
Posts: 73
Joined: Sat Nov 17, 2007 7:07 pm

Re: Building fat boost libraries on OS X

Postby jensverwiebe » Wed Jun 18, 2008 11:19 am

Hi All

I would like to note, that it would be a great idea to put ready universal lib´s in the repository.
So not each builder has to invent the wheel from scratch again. ;)

Thanks Jim and Karl for your work - sorry i hadn´t time the last weeks to get deeper into it.

CU.....Jens
User avatar
jensverwiebe
Developer
 
Posts: 3429
Joined: Wed Apr 02, 2008 4:34 pm

Re: Building fat boost libraries on OS X

Postby jensverwiebe » Thu Aug 21, 2008 7:57 am

Hi
For boost_1_36_0 :

1.: ./configure
2.: ./tools/jam/src/bin.macosxx86/bjam toolset=darwin link=static threading=multi architecture=combined address-model= 32 macosx-version=10.4 macosx-version-min=10.4
3.: repeat 1. + 2. with: ./tools/jam/src/bin.macosxx86/bjam toolset=darwin link=static threading=multi architecture=combined address-model= 64 macosx-version=10.4 macosx-version-min=10.4
now you have libxxx(-arch i386/ppc) and libxxx(-archx_86_64/ppc64)
4.: lipo - create libxxx(-archi386/ppc) libxxx(-archx_86_64/ppc64) -output libxxx for all libs
5. check with command: file libxxx.

This should show now:
Jens-MacPro:~ jensverwiebe$ file /Users/jensverwiebe/bf-blender/luxdevelopment/dependencies/boost_1_36-uni-4-way/libboost_date_time-xgcc40-mt-1_36.a
/Users/jensverwiebe/bf-blender/luxdevelopment/dependencies/boost_1_36-uni-4-way/libboost_date_time-xgcc40-mt-1_36.a: Mach-O universal binary with 4 architectures
/Users/jensverwiebe/bf-blender/luxdevelopment/dependencies/boost_1_36-uni-4-way/libboost_date_time-xgcc40-mt-1_36.a (for architecture i386): current ar archive
/Users/jensverwiebe/bf-blender/luxdevelopment/dependencies/boost_1_36-uni-4-way/libboost_date_time-xgcc40-mt-1_36.a (for architecture ppc): current ar archive
/Users/jensverwiebe/bf-blender/luxdevelopment/dependencies/boost_1_36-uni-4-way/libboost_date_time-xgcc40-mt-1_36.a (for architecture x86_64): current ar archive
/Users/jensverwiebe/bf-blender/luxdevelopment/dependencies/boost_1_36-uni-4-way/libboost_date_time-xgcc40-mt-1_36.a (for architecture ppc64): current ar archive


I have to see if this goes too i 1 step

CU...Jens
User avatar
jensverwiebe
Developer
 
Posts: 3429
Joined: Wed Apr 02, 2008 4:34 pm

Re: Building fat boost libraries on OS X

Postby jensverwiebe » Tue Aug 04, 2009 6:03 am

Hi
For we plan to change to boost 1.39 in the next lux 0.6 RC5 and later, here´s the new instruction for building boost and fix compiling lux in cmakelist.txt.

Boost:

in terminal cd to your boost 1.39 source.....

1.: ./bootstrap.sh --with-toolset=darwin

To build a binary that can run both in 32-bit and 64-bit modes, specify address-model=32_64. If you specify both of those properties, a "4-way" fat binary will be generated.

2.: ./bjam toolset=darwin link=static threading=multi architecture=combined address-model=32_64 macosx-version=10.4 macosx-version-min=10.4


now you have libxxx(-arch i386/ppc/x_86_64/ppc64)

5. check with command: file libxxx. It will show you the arches in the combined lib.



Lux:

In the cmakelist-boost-part, change the OS-related line to match the library-names of boost 1.3.9 and add the boost_system-xgcc40-mt-1_39 , for it is needed now.

Code: Select all
ELSEIF(APPLE)
        SET(Boost_LIBRARIES boost_system-xgcc40-mt-1_39 boost_thread-xgcc40-mt-1_39 boost_program_options-xgcc40-mt-1_39 boost_filesystem-xgcc40-mt-1_39 boost_serialization-xgcc40-mt-1_39 boost_iostreams-xgcc40-mt-1_39 boost_regex-xgcc40-mt-1_39)


I will add boost 1.39 libs as 4-way-universal to luxrenderlib soon.... ( if we all agree to migrate )

Thats it....Jens
User avatar
jensverwiebe
Developer
 
Posts: 3429
Joined: Wed Apr 02, 2008 4:34 pm


Return to Compilation & Portability

Who is online

Users browsing this forum: No registered users and 1 guest