cURL / Mailing Lists / curl-library / Single Mail


Re: Building universal libcurl on Mac OS X 10.5

From: Daniel Johnson <>
Date: Sat, 5 Mar 2011 23:20:29 -0500

On Mar 5, 2011, at 10:17 PM, Cameron Kaiser wrote:

>>> Is there an established way of building curl as Universal Binary?
>> I'm not familiar with the mechanics of making OS X's universal binaries,
>> but I assume that the compiler simply makes three passes through each
>> source file for each architecture specified on the command-line.
> That's exactly what happens. I haven't tried this, but you could add compiler
> flags such as
> -arch ppc -arch i386
> (yes, two -arch flags), which should cause gcc to try to glue them together
> into a fat binary at the end.
> If that fails, you would use lipo to glue two objects together, which always
> works.

This works as long as you're building just an only 32 bit or only 64 bit curl, but not a mixed 32/64 bit one. The problem is that curlbuild.h has macros whose value varies between 32 and 64 bit. If you want a true universal binary you need to do what the MacOSX-Framework script does; do a -arch ppc -arch i386 build and then a -arch ppc64 -arch x86_64 build and lipo the result together. Furthermore, you need to rename curlbuild.h from each to something like curlbuild32.h and curlbuild64.h and make new curlbuild.h that does this:

#ifdef __LP64__
#include "curl/curlbuild64.h"
#include "curl/curlbuild32.h"

Then it'll work. I recommend looking at the MacOSX-Framework script since it does everything you need. You can skip the framework specific stuff if you just want a regular library.


List admin:
Received on 2011-03-06