Skip to content

Compiling CURL on OS X as a Static + Universal binary.

I’ve taken the liberty of adapting the given framework script to produce static libraries. Keep in mind that on Mac OS X 10.6 and > there is no ppc64 support so in order to use this script on that OS you’d first remove that support.


#!/bin/bash
# This script performs all of the steps needed to build a static
# universal binary libcurl.a for Mac OS X 10.5 or greater.

cd curl

VERSION=`/usr/bin/sed -ne 's/^#define LIBCURL_VERSION "\(.*\)"/\1/p' include/curl/curlver.h`

SDK32='/Developer/SDKs/MacOSX10.5.sdk'

MINVER32='-mmacosx-version-min=10.5'

ARCHES32='-arch ppc -arch i386'

SDK64='/Developer/SDKs/MacOSX10.5.sdk'

MINVER64='-mmacosx-version-min=10.5'

ARCHES64='-arch ppc64 -arch x86_64'

echo "----Creating 32 bit ..."

if test -d $SDK32; then
echo "----Configuring libcurl for 32 bit universal ..."
./configure --disable-dependency-tracking --disable-shared \
CFLAGS="-Os -isysroot $SDK32 $ARCHES32 $MINVER32" \
LDFLAGS="-Wl,-syslibroot,$SDK32 $ARCHES32 $MINVER32" \
CC=$CC

echo "----Building 32 bit libcurl..."
make

cp lib/.libs/libcurl.a lib/libcurl32.a

echo "----Creating 64 bit ..."

if test -d $SDK64; then
popd
make clean
echo "----Configuring libcurl for 64 bit universal ..."
./configure --disable-dependency-tracking --disable-shared \
CFLAGS="-Os -isysroot $SDK64 $ARCHES64 $MINVER64" \
LDFLAGS="-Wl,-syslibroot,$SDK64 $ARCHES64 $MINVER64" \
CC=$CC

echo "----Building 64 bit libcurl..."
make

cp lib/.libs/libcurl.a lib/libcurl64.a

echo "----Merging 32 bit and 64 bit ..."

lipo lib/libcurl32.a lib/libcurl64.a -create -output lib/libcurl.a

fi

lipo -info lib/libcurl32.a
lipo -info lib/libcurl64.a
lipo -info lib/libcurl.a

echo "libcurl.a is built and can now be included in other projects."
else
echo "Building libcurl.a requires Mac OS X 10.5 or later with the MacOSX10.5.sdk installed."
fi


CURL

Categories: Code.

Comment Feed

One Response

  1. Thanks for posting this it was essential for a paper I am currently writing for my finals. Thanks

    Gucci Shoes



Some HTML is OK

or, reply to this post via trackback.