Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Boost build script for iOS (armv7, armv7s, arm64), iOS Simulator (i386, x86_64), and OSX (i386, x86_64)
-- 2016-05-18 UPDATE --
ATTENTION:
I have moved this script to an actual github repository. This will allow you all to create issues, make requests,
etc., without me having to remember to check this gist. It also means I will get emails when issues / questions are created.
It will also make it easier (hopefully) to track versioning.
The latest version there has been updated to build for tvOS (along with some other changes).
The new repository is located here:
https://github.com/faithfracture/Apple-Boost-BuildScript
-- 2015-09-22 UPDATE --
Added command line args!
You can now specify if you want to build just for iOS or OS X, along with some other things.
Run boost.sh -h for more info.
Let me know if there are any other parameters that you think would be useful.
-- 2015-09-18 UPDATE --
Fixed script for iOS Simulator (Thanks @XMitja!)
• There is now a MIN_IOS_VERSION variable. Make sure you set this appropriately.
cleanup function now actually removes all build artifacts
Fixed updateBoost function to move the existing user-config.jam instead
of copying it. Copying it resulted in writing duplicate entries each time
the script was run.
NOTE: Currently does not build with bitcode. I will figure that one out when I get time.
I'm at the cusp of a product release though, so it might be a little while.
Just disable bitcode for your project for the time being.
-- 2015-08-26 UPDATE --
The resulting libraries from this script are currently not working for
the iOS simulator under Xcode 7 as of beta 6. I have an issue opened
with Apple about this. It does still work for physical devices though.
As soon as I figure out what the problem is, I will post an update.
-- 2014-12-29 UPDATE --
Updated to work with Boost 1.56, 1.57, and 1.58
Automatically choose the currently selected SDK for both iOS and OSX
Fixed a couple places where the wrong $XXX_DEV_CMD was being used
-- END UPDATE --
This is a modified version of Pete Goodliffe's original boost.sh build script,
(and a couple of other sources whom I can't remember)
The original version didn't work with the 64-bit iPhone Simulator,
and didn't build at all for OSX.
This works for Boost 1.56 and 1.57. If you need the version that builds 1.55 and older, use this revision:
https://gist.github.com/faithfracture/c629ae4c7168216a9856/61be257e1c0839c85743777d0687becad9913bf7
I also ran into an issue where utf8_codecvt_facet.o existed in both the
program_options and filesystem libraries. When linking against the
framework, there was a missing vtable entry for it. Adding the step
in unpackArchive() that prepends the library name to the .o files
prevents this error.
I hope this keeps at least one other person from ripping their hair out.
Let me know if you find errors or have optimizations.
I will be updating this as often as necessary.
#===============================================================================
# Filename: boost.sh
# Author: Pete Goodliffe
# Copyright: (c) Copyright 2009 Pete Goodliffe
# Licence: Please feel free to use this, with attribution
# Modified version
#===============================================================================
#
# Builds a Boost framework for iOS, iOS Simulator, and OSX.
# Creates a set of universal libraries that can be used on an iOS and in the
# iOS simulator. Then creates a pseudo-framework to make using boost in Xcode
# less painful.
#
# To configure the script, define:
# BOOST_VERSION: Which version of Boost to build (e.g. 1.58.0)
# BOOST_VERSION2: Same as BOOST_VERSION, but with _ instead of . (e.g. 1_58_0)
# BOOST_LIBS: Which Boost libraries to build
# MIN_IOS_VERSION: Minimum iOS Target Version (e.g. 8.0)
# IOS_SDK_VERSION: iOS SDK version (e.g. 9.0)
# OSX_SDK_VERSION: OSX SDK version (e.g. 10.11)
#
# If a boost tarball does not exist in the current directory, this script will
# attempt to download the version specified by BOOST_VERSION. You may also
# manually place a matching tarball in the current directory and the script
# will use that.
#
#===============================================================================
BOOST_LIBS="atomic chrono date_time exception filesystem program_options random signals system test thread"
BUILD_IOS=
BUILD_OSX=
CLEAN=
NO_CLEAN=
NO_FRAMEWORK=
BOOST_VERSION=1.58.0
BOOST_VERSION2=1_58_0
MIN_IOS_VERSION=8.0
IOS_SDK_VERSION=`xcodebuild -showsdks | grep iphoneos | \
egrep "[[:digit:]]+\.[[:digit:]]+" -o | tail -1`
OSX_SDK_VERSION=`xcodebuild -showsdks | grep macosx | \
egrep "[[:digit:]]+\.[[:digit:]]+" -o | tail -1`
XCODE_ROOT=`xcode-select -print-path`
# The EXTRA_CPPFLAGS definition works around a thread race issue in
# shared_ptr. I encountered this historically and have not verified that
# the fix is no longer required. Without using the posix thread primitives
# an invalid compare-and-swap ARM instruction (non-thread-safe) was used for the
# shared_ptr use count causing nasty and subtle bugs.
#
# Should perhaps also consider/use instead: -BOOST_SP_USE_PTHREADS
EXTRA_CPPFLAGS="-DBOOST_AC_USE_PTHREADS -DBOOST_SP_USE_PTHREADS -g -DNDEBUG \
-std=c++11 -stdlib=libc++ -fvisibility=hidden -fvisibility-inlines-hidden"
EXTRA_IOS_CPPFLAGS="$EXTRA_CPPFLAGS -mios-version-min=$MIN_IOS_VERSION"
EXTRA_OSX_CPPFLAGS="$EXTRA_CPPFLAGS"
TARBALLDIR=`pwd`
SRCDIR=$TARBALLDIR/src
IOSOUTPUTDIR=$TARBALLDIR/ios
OSXOUTPUTDIR=$TARBALLDIR/osx
IOSBUILDDIR=$IOSOUTPUTDIR/build
OSXBUILDDIR=$OSXOUTPUTDIR/build
PREFIXDIR=$IOSOUTPUTDIR/prefix
IOSFRAMEWORKDIR=$IOSOUTPUTDIR/framework
OSXFRAMEWORKDIR=$OSXOUTPUTDIR/framework
BOOST_TARBALL=$TARBALLDIR/boost_$BOOST_VERSION2.tar.bz2
BOOST_SRC=$SRCDIR/boost_${BOOST_VERSION2}
ARM_DEV_CMD="xcrun --sdk iphoneos"
SIM_DEV_CMD="xcrun --sdk iphonesimulator"
OSX_DEV_CMD="xcrun --sdk macosx"
#===============================================================================
# Functions
#===============================================================================
usage()
{
cat << EOF
usage: $0 options
Build Boost for iOS, iOS Simulator, and OS X
OPTIONS:
-h, -\? | --help
Display these options and exit.
--boost-version
Specify which version of Boost to build. Defaults to $BOOST_VERSION.
-ios
Build for the iOS platform. May be used in conjunction with -osx.
If neither -ios nor -osx are specified, both are built.
-osx
Build for the OS X platform. May be used in conjunction with -ios.
If neither -ios nor -osx are specified, both are built.
--ios-sdk [num]
Specify the iOS SDK version to build with. Defaults to $IOS_SDK_VERSION.
--min-ios-version [num]
Specify the minimum iOS version to target. Defaults to $MIN_IOS_VERSION.
--osx-sdk [num]
Specify the OS X SDK version to build with. Defaults to $OSX_SDK_VERSION.
--no-framework
Do not create the framework.
--clean
Just clean up build artifacts, but don't actually build anything.
--no-clean
Do not clean up existing build artifacts before building.
EOF
}
abort()
{
echo
echo "Aborted: $@"
exit 1
}
die()
{
usage
exit 1
}
missingParameter()
{
echo $1 requires a parameter
die
}
unknownParameter()
{
if [[ -n $2 && $2 != "" ]]; then
echo Unknown argument \"$2\" for parameter $1.
else
echo Unknown argument $1
fi
die
}
parseArgs()
{
while [ "$1" != "" ]; do
case $1 in
-h | -\?)
usage
exit
;;
-ios)
BUILD_IOS=1
;;
-osx)
BUILD_OSX=1
;;
--boost-version)
if [ -n $2 ]; then
BOOST_VERSION=$2
BOOST_VERSION2="${BOOST_VERSION//./_}"
BOOST_TARBALL=$TARBALLDIR/boost_$BOOST_VERSION2.tar.bz2
BOOST_SRC=$SRCDIR/boost_${BOOST_VERSION2}
shift
else
missingParameter $1
fi
;;
--ios-sdk)
if [ -n $2 ]; then
IOS_SDK_VERSION=$2
shift
else
missingParameter $1
fi
;;
--min-ios-version)
if [ -n $2 ]; then
MIN_IOS_VERSION=$2
shift
else
missingParameter $1
fi
;;
--osx-sdk)
if [ -n $2 ]; then
OSX_SDK_VERSION=$2
shift
else
missingParameter $1
fi
;;
--clean)
CLEAN=1
;;
--no-clean)
NO_CLEAN=1
;;
--no-framework)
NO_FRAMEWORK=1
;;
*)
unknownParameter $1
;;
esac
shift
done
}
doneSection()
{
echo
echo "Done"
echo "================================================================="
echo
}
#===============================================================================
cleanup()
{
echo Cleaning everything
rm -rf $BOOST_SRC/iphone-build
rm -rf $BOOST_SRC/iphonesim-build
rm -rf $BOOST_SRC/osx-build
rm -rf $IOSOUTPUTDIR
rm -rf $OSXOUTPUTDIR
doneSection
}
#===============================================================================
downloadBoost()
{
if [ ! -s $BOOST_TARBALL ]; then
echo "Downloading boost ${BOOST_VERSION}"
curl -L -o $BOOST_TARBALL \
http://sourceforge.net/projects/boost/files/boost/${BOOST_VERSION}/boost_${BOOST_VERSION2}.tar.bz2/download
fi
doneSection
}
#===============================================================================
unpackBoost()
{
[ -f "$BOOST_TARBALL" ] || abort "Source tarball missing."
echo Unpacking boost into $SRCDIR...
[ -d $SRCDIR ] || mkdir -p $SRCDIR
[ -d $BOOST_SRC ] || ( cd $SRCDIR; tar xfj $BOOST_TARBALL )
[ -d $BOOST_SRC ] && echo " ...unpacked as $BOOST_SRC"
doneSection
}
#===============================================================================
inventMissingHeaders()
{
# These files are missing in the ARM iPhoneOS SDK, but they are in the simulator.
# They are supported on the device, so we copy them from x86 SDK to a staging area
# to use them on ARM, too.
echo Invent missing headers
cp $XCODE_ROOT/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${IOS_SDK_VERSION}.sdk/usr/include/{crt_externs,bzlib}.h $BOOST_SRC
}
#===============================================================================
updateBoost()
{
echo Updating boost into $BOOST_SRC...
mv $BOOST_SRC/tools/build/src/user-config.jam $BOOST_SRC/tools/build/src/user-config.jam-bk
if [[ -n $BUILD_IOS ]]; then
cat >> $BOOST_SRC/tools/build/src/user-config.jam <<EOF
using darwin : ${IOS_SDK_VERSION}~iphone
: $XCODE_ROOT/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch armv7 \
-arch armv7s -arch arm64 $EXTRA_IOS_CPPFLAGS
: <striper> <root>$XCODE_ROOT/Platforms/iPhoneOS.platform/Developer
: <architecture>arm <target-os>iphone
;
using darwin : ${IOS_SDK_VERSION}~iphonesim
: g++ -arch i386 -arch x86_64 $EXTRA_IOS_CPPFLAGS
: <striper> <root>$XCODE_ROOT/Platforms/iPhoneSimulator.platform/Developer
: <architecture>x86 <target-os>iphone
;
EOF
fi
if [[ -n $BUILD_OSX ]]; then
cat >> $BOOST_SRC/tools/build/src/user-config.jam <<EOF
using darwin : ${OSX_SDK_VERSION}
: g++ -arch i386 -arch x86_64 $EXTRA_OSX_CPPFLAGS
: <striper> <root>$XCODE_ROOT/Platforms/MacOSX.platform/Developer
: <architecture>x86 <target-os>darwin
;
EOF
fi
doneSection
}
#===============================================================================
bootstrapBoost()
{
cd $BOOST_SRC
BOOST_LIBS_COMMA=$(echo $BOOST_LIBS | sed -e "s/ /,/g")
echo "Bootstrapping (with libs $BOOST_LIBS_COMMA)"
./bootstrap.sh --with-libraries=$BOOST_LIBS_COMMA
doneSection
}
#===============================================================================
buildBoost()
{
cd $BOOST_SRC
if [[ -n $BUILD_IOS ]]; then
echo Building Boost for iPhone
# Install this one so we can copy the headers for the frameworks...
./b2 -j16 --build-dir=iphone-build --stagedir=iphone-build/stage \
--prefix=$PREFIXDIR toolset=darwin architecture=arm target-os=iphone \
macosx-version=iphone-${IOS_SDK_VERSION} define=_LITTLE_ENDIAN \
link=static stage
./b2 -j16 --build-dir=iphone-build --stagedir=iphone-build/stage \
--prefix=$PREFIXDIR toolset=darwin architecture=arm \
target-os=iphone macosx-version=iphone-${IOS_SDK_VERSION} \
define=_LITTLE_ENDIAN link=static install
doneSection
echo Building Boost for iPhoneSimulator
./b2 -j16 --build-dir=iphonesim-build --stagedir=iphonesim-build/stage \
toolset=darwin-${IOS_SDK_VERSION}~iphonesim architecture=x86 \
target-os=iphone macosx-version=iphonesim-${IOS_SDK_VERSION} \
link=static stage
doneSection
fi
if [[ -n $BUILD_OSX ]]; then
echo building Boost for OSX
./b2 -j16 --build-dir=osx-build --stagedir=osx-build/stage toolset=clang \
cxxflags="-std=c++11 -stdlib=libc++ -arch i386 -arch x86_64" \
linkflags="-stdlib=libc++" link=static threading=multi \
macosx-version=${OSX_SDK_VERSION} stage
# If we are only building for OS X and we are outputting a framework,
# then we need to install this one so we can copy the headers
if [[ -z $BUILD_IOS && -z $NO_FRAMEWORK ]]; then
PREFIXDIR=$OSXBUILDDIR/prefix
./b2 -j16 --build-dir=osx-build --stagedir=osx-build/stage \
--prefix=$PREFIXDIR toolset=clang \
cxxflags="-std=c++11 -stdlib=libc++ -arch i386 -arch x86_64" \
linkflags="-stdlib=libc++" link=static threading=multi \
macosx-version=${OSX_SDK_VERSION} install
fi
doneSection
fi
}
#===============================================================================
unpackArchive()
{
BUILDDIR=$1
LIBNAME=$2
echo "Unpacking $LIBNAME"
if [[ -d $BUILDDIR/$LIBNAME ]]; then
rm $BUILDDIR/$LIBNAME/*.o
rm $BUILDDIR/$LIBNAME/*.SYMDEF*
else
mkdir -p $BUILDDIR/$LIBNAME
fi
(
cd $BUILDDIR/$NAME; ar -x ../../libboost_$NAME.a;
for FILE in *.o; do
NEW_FILE="${NAME}_${FILE}"
mv $FILE $NEW_FILE
done
)
}
scrunchAllLibsTogetherInOneLibPerPlatform()
{
cd $BOOST_SRC
if [[ -n $BUILD_IOS ]]; then
# iOS Device
mkdir -p $IOSBUILDDIR/armv7/obj
mkdir -p $IOSBUILDDIR/armv7s/obj
mkdir -p $IOSBUILDDIR/arm64/obj
# iOS Simulator
mkdir -p $IOSBUILDDIR/i386/obj
mkdir -p $IOSBUILDDIR/x86_64/obj
fi
if [[ -n $BUILD_OSX ]]; then
# OSX
mkdir -p $OSXBUILDDIR/i386/obj
mkdir -p $OSXBUILDDIR/x86_64/obj
fi
ALL_LIBS=""
echo Splitting all existing fat binaries...
for NAME in $BOOST_LIBS; do
if [ "$NAME" == "test" ]; then
NAME="unit_test_framework"
fi
ALL_LIBS="$ALL_LIBS libboost_$NAME.a"
if [[ -n $BUILD_IOS ]]; then
$ARM_DEV_CMD lipo "iphone-build/stage/lib/libboost_$NAME.a" \
-thin armv7 -o $IOSBUILDDIR/armv7/libboost_$NAME.a
$ARM_DEV_CMD lipo "iphone-build/stage/lib/libboost_$NAME.a" \
-thin armv7s -o $IOSBUILDDIR/armv7s/libboost_$NAME.a
$ARM_DEV_CMD lipo "iphone-build/stage/lib/libboost_$NAME.a" \
-thin arm64 -o $IOSBUILDDIR/arm64/libboost_$NAME.a
$SIM_DEV_CMD lipo "iphonesim-build/stage/lib/libboost_$NAME.a" \
-thin i386 -o $IOSBUILDDIR/i386/libboost_$NAME.a
$SIM_DEV_CMD lipo "iphonesim-build/stage/lib/libboost_$NAME.a" \
-thin x86_64 -o $IOSBUILDDIR/x86_64/libboost_$NAME.a
fi
if [[ -n $BUILD_OSX ]]; then
$OSX_DEV_CMD lipo "osx-build/stage/lib/libboost_$NAME.a" \
-thin i386 -o $OSXBUILDDIR/i386/libboost_$NAME.a
$OSX_DEV_CMD lipo "osx-build/stage/lib/libboost_$NAME.a" \
-thin x86_64 -o $OSXBUILDDIR/x86_64/libboost_$NAME.a
fi
done
echo "Decomposing each architecture's .a files"
for NAME in $BOOST_LIBS; do
if [ "$NAME" == "test" ]; then
NAME="unit_test_framework"
fi
echo "Decomposing libboost_${NAME}.a"
if [[ -n $BUILD_IOS ]]; then
unpackArchive "$IOSBUILDDIR/armv7/obj" $NAME
unpackArchive "$IOSBUILDDIR/armv7s/obj" $NAME
unpackArchive "$IOSBUILDDIR/arm64/obj" $NAME
unpackArchive "$IOSBUILDDIR/i386/obj" $NAME
unpackArchive "$IOSBUILDDIR/x86_64/obj" $NAME
fi
if [[ -n $BUILD_OSX ]]; then
unpackArchive "$OSXBUILDDIR/i386/obj" $NAME
unpackArchive "$OSXBUILDDIR/x86_64/obj" $NAME
fi
done
echo "Linking each architecture into an uberlib ($ALL_LIBS => libboost.a )"
if [[ -n $BUILD_IOS ]]; then
rm $IOSBUILDDIR/*/libboost.a
fi
if [[ -n $BUILD_OSX ]]; then
rm $OSXBUILDDIR/*/libboost.a
fi
for NAME in $BOOST_LIBS; do
if [ "$NAME" == "test" ]; then
NAME="unit_test_framework"
fi
echo $NAME
if [[ -n $BUILD_IOS ]]; then
echo ...armv7
(cd $IOSBUILDDIR/armv7; $ARM_DEV_CMD ar crus libboost.a obj/$NAME/*.o; )
echo ...armv7s
(cd $IOSBUILDDIR/armv7s; $ARM_DEV_CMD ar crus libboost.a obj/$NAME/*.o; )
echo ...arm64
(cd $IOSBUILDDIR/arm64; $ARM_DEV_CMD ar crus libboost.a obj/$NAME/*.o; )
echo ...i386
(cd $IOSBUILDDIR/i386; $SIM_DEV_CMD ar crus libboost.a obj/$NAME/*.o; )
echo ...x86_64
(cd $IOSBUILDDIR/x86_64; $SIM_DEV_CMD ar crus libboost.a obj/$NAME/*.o; )
fi
if [[ -n $BUILD_OSX ]]; then
echo ...osx-i386
(cd $OSXBUILDDIR/i386; $OSX_DEV_CMD ar crus libboost.a obj/$NAME/*.o; )
echo ...osx-x86_64
(cd $OSXBUILDDIR/x86_64; $OSX_DEV_CMD ar crus libboost.a obj/$NAME/*.o; )
fi
done
}
#===============================================================================
buildFramework()
{
: ${1:?}
FRAMEWORKDIR=$1
BUILDDIR=$2
VERSION_TYPE=Alpha
FRAMEWORK_NAME=boost
FRAMEWORK_VERSION=A
FRAMEWORK_CURRENT_VERSION=$BOOST_VERSION
FRAMEWORK_COMPATIBILITY_VERSION=$BOOST_VERSION
FRAMEWORK_BUNDLE=$FRAMEWORKDIR/$FRAMEWORK_NAME.framework
echo "Framework: Building $FRAMEWORK_BUNDLE from $BUILDDIR..."
rm -rf $FRAMEWORK_BUNDLE
echo "Framework: Setting up directories..."
mkdir -p $FRAMEWORK_BUNDLE
mkdir -p $FRAMEWORK_BUNDLE/Versions
mkdir -p $FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION
mkdir -p $FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/Resources
mkdir -p $FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/Headers
mkdir -p $FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/Documentation
echo "Framework: Creating symlinks..."
ln -s $FRAMEWORK_VERSION $FRAMEWORK_BUNDLE/Versions/Current
ln -s Versions/Current/Headers $FRAMEWORK_BUNDLE/Headers
ln -s Versions/Current/Resources $FRAMEWORK_BUNDLE/Resources
ln -s Versions/Current/Documentation $FRAMEWORK_BUNDLE/Documentation
ln -s Versions/Current/$FRAMEWORK_NAME $FRAMEWORK_BUNDLE/$FRAMEWORK_NAME
FRAMEWORK_INSTALL_NAME=$FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/$FRAMEWORK_NAME
echo "Lipoing library into $FRAMEWORK_INSTALL_NAME..."
$ARM_DEV_CMD lipo -create $BUILDDIR/*/libboost.a -o "$FRAMEWORK_INSTALL_NAME" || abort "Lipo $1 failed"
echo "Framework: Copying includes..."
cp -r $PREFIXDIR/include/boost/* $FRAMEWORK_BUNDLE/Headers/
echo "Framework: Creating plist..."
cat > $FRAMEWORK_BUNDLE/Resources/Info.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${FRAMEWORK_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.boost</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${FRAMEWORK_CURRENT_VERSION}</string>
</dict>
</plist>
EOF
doneSection
}
#===============================================================================
restoreBoost()
{
cp $BOOST_SRC/tools/build/src/user-config.jam-bk $BOOST_SRC/tools/build/src/user-config.jam
}
#===============================================================================
# Execution starts here
#===============================================================================
parseArgs $@
if [ -n "$CLEAN" ]; then
cleanup
exit
fi
if [[ -z $BUILD_IOS && -z $BUILD_OSX ]]; then
BUILD_IOS=1
BUILD_OSX=1
fi
format="%-20s %s\n"
printf "$format" "BUILD_IOS:" $( [[ -n $BUILD_IOS ]] && echo "YES" || echo "NO")
printf "$format" "BUILD_OSX:" $( [[ -n $BUILD_OSX ]] && echo "YES" || echo "NO")
printf "$format" "BOOST_VERSION:" $BOOST_VERSION
printf "$format" "IOS_SDK_VERSION:" $IOS_SDK_VERSION
printf "$format" "OSX_SDK_VERSION:" $OSX_SDK_VERSION
printf "$format" "MIN_IOS_VERSION:" $MIN_IOS_VERSION
printf "$format" "BOOST_LIBS:" "$BOOST_LIBS"
printf "$format" "BOOST_SRC:" $BOOST_SRC
printf "$format" "IOSBUILDDIR:" $IOSBUILDDIR
printf "$format" "OSXBUILDDIR:" $OSXBUILDDIR
printf "$format" "PREFIXDIR:" $PREFIXDIR
printf "$format" "IOSFRAMEWORKDIR:" $IOSFRAMEWORKDIR
printf "$format" "OSXFRAMEWORKDIR:" $OSXFRAMEWORKDIR
printf "$format" "XCODE_ROOT:" $XCODE_ROOT
echo
if [ -z $NO_CLEAN ]; then
cleanup
fi
downloadBoost
unpackBoost
inventMissingHeaders
bootstrapBoost
updateBoost
buildBoost
scrunchAllLibsTogetherInOneLibPerPlatform
if [ -z $NO_FRAMEWORK ]; then
if [[ -n $BUILD_IOS ]]; then
buildFramework $IOSFRAMEWORKDIR $IOSBUILDDIR
fi
if [[ -n $BUILD_OSX ]]; then
buildFramework $OSXFRAMEWORKDIR $OSXBUILDDIR
fi
fi
restoreBoost
echo "Completed successfully"
@enrighd

This comment has been minimized.

Copy link

enrighd commented Sep 18, 2014

I have be trying to get this to work with a c++ library in xcode and i get this error when i run this script any help would be much appreciated. I am trying to build it for the serialization library only.

Lipoing library into /Users/username/Desktop/boost/ios/framework/boost.framework/Versions/A/boost...
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: empty archive with no architecture specification: /Users/username/Desktop/boost/ios/build/arm64/libboost.a (can't determine architecture for it)

@ansons

This comment has been minimized.

Copy link

ansons commented Sep 18, 2014

I am having the same issue. In my situation, the bjam failed to locate "sdks" properly so it terminated all build ops. When the boost.sh script tried to lipo the library, it cannot find the binaries it needs so it throws the error you saw.

I have not figured out how to fix it.

@faithfracture

This comment has been minimized.

Copy link
Owner Author

faithfracture commented Oct 20, 2014

You're going to have to comb through the boost build logs and see what's not getting compiled. One of the boost libraries is failing to build, so it can't lipo everything together. Which version of Xcode are you using? This works for me with both Xcode 5.1.1 and 6.0.1.

@IDSeeX

This comment has been minimized.

Copy link

IDSeeX commented Oct 23, 2014

../libboost_random.a:No Such file ofr directory, why?

@faithfracture

This comment has been minimized.

Copy link
Owner Author

faithfracture commented Oct 28, 2014

At what point in the process? There's different places that can happen.

@meshula

This comment has been minimized.

Copy link

meshula commented Dec 26, 2014

It's mildly hilarious that this sort of info and technique can't be found on the boost site...

FWIW, I maintain a shell script and set of configuration files here -

https://github.com/meshula/boost-build-club.git

that currently work. I borrowed some of the ideas from this gist and from Pete Goodliffe's original. Note that my script does not package things up into a framework because I prefer a more linux like build env.

@faithfracture

This comment has been minimized.

Copy link
Owner Author

faithfracture commented Dec 29, 2014

Hilarious is one word for it, especially now that I know what I'm doing with it. When I was on day 3 or 4 of trying to get it to build and link correctly for everything I needed it to do though, "hilarious" was probably the last adjective I would have used.

@thierryseegers

This comment has been minimized.

Copy link

thierryseegers commented Jan 9, 2015

Hi faithfracture,

First, thanks for sharing your efforts! I'm certainly appreciating it.

I have a question/suggestion. For my situation, rather than end up with a libboost.a for each platform, I'd prefer to have a fat libboost_X.a for all architectures. e.g. a libboost_filesystem.a that includes arm*, i386 and x86_64 from iphone, ios and macos. Is that feasible? If it is, would it be possible to add another function to your script to provide that output?

I naively tried the following command:

lipo iphone-build/stage/lib/libboost_filesystem.a iphonesim-build/stage/lib/libboost_filesystem.a osx-build/stage/lib/libboost_filesystem.a -output libboost_filesystem.a -create

but I was met with this error message which complained about a "duplicate" architecture:

iphonesim-build/stage/lib/libboost_filesystem.a and osx-build/stage/lib/libboost_filesystem.a have the same architectures (i386) and can't be in the same fat output file

Does that imply that iphonesim-i386 and macos-i386 can't ever live in the same file? And are they truly different?

Thanks!

@faithfracture

This comment has been minimized.

Copy link
Owner Author

faithfracture commented Jan 23, 2015

It is possible to create individual, universal libraries for each boost library for iOS and OS X separately (i.e. libboost_X.a for each Boost library being built), but I don't know about combining them to create a "super-universal" file. My initial thought is that iphonesim-i386 and macos-i386, since they are both i386, are actually the same thing (after all, they are both built to run in an OS X environment), so you should be able to skip one or the other and link against the library when building for either one. I don't know that for sure though, since A) I know basically nothing about how the compiler treats each platform (except that if I get it wrong, we hate each other for the rest of the day until one of us (me) figures out what the other on (clang) wants), and B) I don't have a MacOSX project I'm working on that uses Boost. (I suppose I could make up a test project and try it out though).

My other thought though is that you aren't going to have a project that builds both for iOS and OS X (are you? can you even do that?), so having one single library that contains all architectures doesn't really make sense. If you have two separate projects, you're going to have to set up the library dependancies anyways, so why not just link to the appropriate library?

** I'm not trying to say your idea is in any way stupid. You may very well have a situation where having one single mega-library makes sense. I just can't think of a situation where it would be necessary. **

@thierryseegers

This comment has been minimized.

Copy link

thierryseegers commented Feb 10, 2015

Hello again, and thanks for taking the time to reply.

To answer your questions, I have a codebase that outputs an iPhone app and also some cross-platform command-line tools and all use some common code. (CMake is used to generate two separate Xcode project files on the Mac, one for iOS targets and one for MacOS targets). Combine that with the fact that in my own personal experience, I always had boost libraries committed in my codebase in the fashion I describe above and that explains my query of "Hey, can I have a libboost-X.a for all platforms combined in the way I like it?".

Now the funny part, I tried it out quickly for fun! That is, in my Xcode project for MacOS tools, I linked against the boost libs compiled for iOS archs (i386 + x86_64 + armv7 + arm64) and, well, the linker didn't complain... OK, let's run this!

Didn't work. :( That is, the first piece of boost code I ran was to iterate files over a folder with boost_filesystem. It just failed silently, finding no files. As soon as I went back to linking against MacOS targeted libs, it worked fine. Why? How? I don't know and, like you, I don't have the energy to figure it out. :)

So, that's that. And, for my purposes, I can always lipo what I want from the intermediary libs your script creates. So it's all cool.

@Petahwil

This comment has been minimized.

Copy link

Petahwil commented Feb 12, 2015

Hello,

Thanks for the good download. Though i am having one issue with the boost i am trying to use the OS X 10.10 and Xcode 6.1.1? If you could point me in the right direction that would be awesome!

Undefined symbols for architecture x86_64:
"boost::unit_test::unit_test_main(bool ()(), int, char*)", referenced from:
_main in test.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@zsoltbalint

This comment has been minimized.

Copy link

zsoltbalint commented Mar 10, 2015

Hello,

The framework compiles correctly on OS X 10.10, but when I try to use it I'm receiving the following error in Xcode 6.1.1:
http://pastebin.com/2N7tpDru

@faithfracture

This comment has been minimized.

Copy link
Owner Author

faithfracture commented Mar 31, 2015

Petahwil :
This is a linker error. It's telling you that it can't find a method "boost::unit_test::unit_test_main(bool ()(), int, char*)" in any of the libraries your project is linking against that is built for the x86_64 (64-bit) architecture. I would start by making sure that your project's library search path is set to the correct directories for the 64-bit versions. If you are using the boost.framework that this script produces, make sure you have it set in your project's framework search path.

zsoltbalint :
It looks to me like boost is using std::basic_string and the linker can't find a library built for the x86_64 architecture. I think this is a problem with the c++ standard library your project is linking against and not a problem with Boost.

@faithfracture

This comment has been minimized.

Copy link
Owner Author

faithfracture commented Mar 31, 2015

Just so everyone knows, GitHub does NOT send notifications when someone comments on a GIST. If you comment on here with a question, feel free to let me know via twitter @jordanbondo

@emersonxsu

This comment has been minimized.

Copy link

emersonxsu commented May 5, 2015

Sadly doesn't work. Any update to XCODE 6.3 with newest boost_1_58_0?

@faithfracture

This comment has been minimized.

Copy link
Owner Author

faithfracture commented May 6, 2015

You're going to have to be more specific. What doesn't work? I'm using Xcode 6.3 and the script works fine for me. There are some things that changed in Boost itself that required a few code changes on my end, but as far as the script goes it built the libraries just fine.

@danoli3

This comment has been minimized.

Copy link

danoli3 commented May 29, 2015

Pete Goodliffe's original script was licensed, use with attribution. Might want to re-add his copyright.

Anyway here is my variant used for static libs for iOS supporting both libc++ / libstdc++.
https://github.com/danoli3/ofxiOSBoost

Some of the above issues may have been related to libc++/libstdc++ conflicts based on project settings... specifically that string one @zsoltbalint

@kid304

This comment has been minimized.

Copy link

kid304 commented Jun 28, 2015

Undefined symbols for architecture x86_64:
"boost::serialization::typeid_system::extended_type_info_typeid_0::type_register(std::type_info const&)", referenced from:
boost::serialization::extended_type_info_typeid<std::__1::pair<int const, int> >::extended_type_info_typeid() in DictReader.o

I got this error when using the boost.framework . can you show me how to fix it ?

@parfenuk

This comment has been minimized.

Copy link

parfenuk commented Jul 6, 2015

I have a trouble in my project 'Undefined symbols for architecture arm64' so I had to rebuild boost.framework for it to support this architecture.
What I did: (sorry for very detailed explanation - I really dunno what to do now)

  1. I downloaded your script and ran it with a command 'sh boost.sh' in the terminal.
  2. Then I went into ios/framework/boost.framework and imported it into my project instead of existing one (in my project this framework has the same representation).
  3. I tried to build my project but I got an error like above (Undefined symbols) both for armv7 and arm64-architectures.
  4. But when I replaced executable file (named boost) from my old framework - it was built succesfully for armv7 and still wasn't built for arm64-architecture.

I tried to change C++ Language Dialect and C++ standard library - but it didn't help me.
I use 1.49.0 version of the framework (yes, it's very old, but my project doesn't support newer versions for the certain reasons)
Maybe, I import the framework in some wrong way. Could you please advise me what to do?
And anyway big thanks for your job. It still gives me a hope :)
(The same trouble occurs for all other shell scripts I found)

Here's the list of undefined symbols for arm64 I have:
Undefined symbols for architecture arm64:
"boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits > >::construct_init(boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits > > const&, boost::regex_constants::_match_flags)", referenced from:
boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits > >::perl_matcher(__gnu_cxx::__normal_iterator<char const*, std::string>, __gnu_cxx::__normal_iterator<char const*, std::string>, boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits > > const&, boost::regex_constants::_match_flags, gnu_cxx::normal_iterator<char const*, std::string>) in libMonkSVG_iOS.a(mkSVG.o)
"boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits > >::do_assign(char const
, char const
, unsigned int)", referenced from:
boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits > >::assign(char const
, char const
, unsigned int) in libMonkSVG_iOS.a(mkSVG.o)
"boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits > >::find()", referenced from:
bool boost::regex_search<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, char, boost::regex_traits<char, boost::cpp_regex_traits > >(__gnu_cxx::__normal_iterator<char const*, std::string>, __gnu_cxx::__normal_iterator<char const*, std::string>, boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits > > const&, boost::regex_constants::_match_flags, __gnu_cxx::__normal_iterator<char const*, std::string>) in libMonkSVG_iOS.a(mkSVG.o)

@faithfracture

This comment has been minimized.

Copy link
Owner Author

faithfracture commented Jul 9, 2015

Guys, this script does not build every single boost library by default, only the ones _I_ need in _my_ project. If you want to use serialization and regex, you have to say so.

At the top of the script is the line:

: ${BOOST_LIBS:="atomic chrono date_time exception filesystem program_options random signals system test thread"}

You need to customize this list in order for the libraries you want to be compiled into the framework.

Without knowing exactly what your are using, I can only guess what you need to include, but my best guess is that:
@kid304, you need to include io_streams
@parfenuk, you need to include regex

another option is to not include anything special and just say:

: @{BOOST_LIBS:="all"}

Just know that will make your framework a lot bigger than it needs to be if you aren't using all the Boost libraries.

@rokoDev

This comment has been minimized.

Copy link

rokoDev commented Aug 5, 2015

Thank you for this useful script but when i try to replace

${BOOST_LIBS:="atomic chrono date_time exception filesystem program_options random signals system test thread"}

with

${BOOST_LIBS:="spirit"}

it fails with log:
http://pastebin.com/t4XQVvdR

What name should i specify for boost::spirit ?

@faithfracture

This comment has been minimized.

Copy link
Owner Author

faithfracture commented Aug 6, 2015

@rokoDev - I replied to you on twitter, but I'll post it here too for others that are interested.

Most of Boost is header only, meaning you don't need to specify it as a library that needs building - you get it for free in the includes. Spirit is one of those libraries.

Here is a link to the Boost documentation for which libraries actually DO need building. If it's not in this list (for Boost 1.58.0), you don't need to specify it.

http://www.boost.org/doc/libs/1_58_0/more/getting_started/unix-variants.html#header-only-libraries

@Reithan

This comment has been minimized.

Copy link

Reithan commented Aug 17, 2015

I've tried everything I can think of (not that that's much given how green I am to Mac development), but I can't get rid of this error whenever I try to use the framework generated. I commented out everything to do with OSX in the script, leaving only the iPhone & iPhone-Simulator sections, and even still, I get:

ld: in /Users/MyName/Downloads/ios/framework/boost.framework/boost(filesystem_path.o), building for iOS simulator, but linking in object file built for OSX, for architecture i386
@rohitdhiman

This comment has been minimized.

Copy link

rohitdhiman commented Aug 24, 2015

Hi,
I have created framework (boost.framework) from the above given script for same tar (boost_1_56_0.tar.bz2) using XCode6.4.. I am getting issue while compiling code:
Undefined symbols for architecture i386:
"init_unit_test_suite(int, char**)", referenced from:
_main in boost(unit_test_framework_unit_test_main.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation).

screen shot 2015-08-25 at 2 49 25 am

Please provide help on this.

@faithfracture

This comment has been minimized.

Copy link
Owner Author

faithfracture commented Aug 27, 2015

@rohitdhiman I don't know how you are using the unit test framework, so I'm not sure where that is coming from. There are a lot of different variables that could be causing that. If you can push your project (or a small similar project with that gives the same error) to a public repo somewhere I would be happy to take a look at it.

@XMitja

This comment has been minimized.

Copy link

XMitja commented Sep 17, 2015

To enable simulator builds you have to specify minimum deployment target in the CPPFLAGS with -mios-version-min or -miphoneos-version-min so something like:
: ${EXTRA_CPPFLAGS:="-DBOOST_AC_USE_PTHREADS -DBOOST_SP_USE_PTHREADS -g -DNDEBUG -std=c++11 -stdlib=libc++ -mios-version-min=6.0"}
should work
reference:
http://www.openradar.me/21724015

@faithfracture

This comment has been minimized.

Copy link
Owner Author

faithfracture commented Sep 18, 2015

OMG! Thanks @XMitja!

@amesh90

This comment has been minimized.

Copy link

amesh90 commented Sep 20, 2015

Many Thanks for your effort, but I've tried to build boost using boost.sh
and I got those errors :

http://pastebin.com/deM1QKZT

and it's the same for building for IOSsimulator and OSX as well

@faithfracture

This comment has been minimized.

Copy link
Owner Author

faithfracture commented Sep 21, 2015

@amesh90 It says there's a syntax error in user-config.jam at keyword | (I assume that's a pipe?) The entire user-config.jam is written in the updateBoost() function, and there is no pipe in there, so I don't know where that's coming from. There are some macros that get expanded there, so it might have something to do with your $PATH. Can you paste the entire contents of /Users/arlab/ros_for_ios/boostonios/src/boost_1_58_0/tools/build/src/user-config.jam ?

@amesh90

This comment has been minimized.

Copy link

amesh90 commented Sep 21, 2015

@faithfracture here is the content of user-config.jam

http://pastebin.com/iFZft5rN

it contains pipe operator |
and I don't know where should I investigate the problem

@faithfracture

This comment has been minimized.

Copy link
Owner Author

faithfracture commented Sep 21, 2015

Ok, I see a couple problems:

1 - I've had problems when the path contained a space. Your Xcode app has a space in its name: "Xcode 3.app". I would try renaming this to remove the space (Xcode3.app or Xcode_3.app or something like that).

2 - Are you really using Xcode 3? If so, I don't know how you're getting the iOS 8.1 SDK. Something might be awry with your Xcode installation.

3 - I think the root of the issue is that the command to find your OS X SDK version is not evaluating correctly. (the 3rd 'using darwin' statement) What happens if you run the command

xcodebuild -showsdks | grep macosx | egrep "[[:digit:]]+.[[:digit:]]+" -o | tail -1

directly from a command prompt? It should evaluate to '10.10' or something like that.

If you do not need Boost built for OS X, you can remove that part of the build process.
Try this: http://pastebin.com/Tf6yhQkb

@wtsnz

This comment has been minimized.

Copy link

wtsnz commented Sep 23, 2015

This is golden - thanks @faithfracture!

Another improvement could be to add bitcode support. Which I believe is as simple as adding -fembed-bitcode to the EXTRA_CPPFLAGS. I will give this a shot and let you know.

@faithfracture

This comment has been minimized.

Copy link
Owner Author

faithfracture commented Sep 23, 2015

@wtsnz - Thanks :) I've been wanting to add CLI args for quite a while. I got really really tired of commenting & uncommenting stuff, so I finally made some free time to do it.
Regarding bitcode support, I did try adding that flag, but I got an error about enabling bitcode and having multiple architectures defined at the same time, so the build command will have to be split out individually for each arch I think. I didn't have time to dig into it, so if you get it working let me know and I'll add it.

@mhaylock

This comment has been minimized.

Copy link

mhaylock commented Oct 29, 2015

@faithfracture I notice that when I provide --boost-version 1.55.0 the BOOST_SRC printed is still src/boost_1_58_0.

@mhaylock

This comment has been minimized.

Copy link

mhaylock commented Oct 29, 2015

Infact after downloading the tarsal it then fails with Aborted: Source tarball missing.

@mhaylock

This comment has been minimized.

Copy link

mhaylock commented Oct 29, 2015

@faithfracture I've fixed that bug on my fork (see https://gist.github.com/mhaylock/2889d081525e589c7cae). 1.55.0 still doesn't compile (too old?) but 1.57.0 specified from the command line compiled fine after my fix.

@faithfracture

This comment has been minimized.

Copy link
Owner Author

faithfracture commented Nov 4, 2015

Ah, good catch. I'll update this script with that.

Boost 1.55.0 used a different directory structure, so you can't build it with this script without some modification. I think all you need to do is change the lines in updateBoost() from:

mv $BOOST_SRC/tools/build/src/user-config.jam $BOOST_SRC/tools/build/src/user-config.jam-bk
...
cat >> $BOOST_SRC/tools/build/src/user-config.jam <<EOF
...
cat >> $BOOST_SRC/tools/build/src/user-config.jam <<EOF

to

mv $BOOST_SRC/tools/build/v2/user-config.jam $BOOST_SRC/tools/build/src/user-config.jam-bk
...
cat >> $BOOST_SRC/tools/build/v2/user-config.jam <<EOF
...
cat >> $BOOST_SRC/tools/build/v2/user-config.jam <<EOF

(short: change build/src to build/v2)

There might be more things that need changing, but I don't recall for sure. The original version of this script that I uploaded was originally for building Boost 1.55.0, so you might check the revisions. If I remember correctly, there was a problem with building for 64-bit iOS (I don't remember if it was for the simulator or arm64 or both). There was a patch file that we had to download from the Boost developer forum and manually patch the source.

@spanndemic

This comment has been minimized.

Copy link

spanndemic commented Nov 11, 2015

Don't suppose anyone has attempted to do a similar build for tvOS or watchOS? Trying to publish to an AppleTV with the framework generated with this script results in a linker error (ld: in (path)/ios/framework/boost.framework/boost(thread_thread.o), building for tvOS, but linking in object file built for iOS, for architecture arm64)

@spanndemic

This comment has been minimized.

Copy link

spanndemic commented Nov 16, 2015

Here is an alternate script for tvOS if anyone is looking for it:

https://github.com/danoli3/ofxtvOSBoost

@arunrajagopalan

This comment has been minimized.

Copy link

arunrajagopalan commented Jan 2, 2016

Hi - Thanks for sharing this script !

I am trying to use http://www.codeproject.com/Articles/692787/Best-fitting-line-circle-and-ellipse for iOS. I modified it to not use program_options.

So the only library it needs is ublas which doesn't need to be compiled. The program compiles and runs great in OS X with stock 1.60.0 even without this script

But with iOS, i get the following error. I am using this script with 1.58.0. I am including the directory ios/prefix/include

Any help would be greatly appreciated

In file included from ./ellipsefit/BestFit.h:17:
In file included from /Users/arunrajagopalan/work/boost_iOS/ios/prefix/include/boost/numeric/ublas/banded.hpp:16:
In file included from /Users/arunrajagopalan/work/boost_iOS/ios/prefix/include/boost/numeric/ublas/matrix.hpp:18:
In file included from /Users/arunrajagopalan/work/boost_iOS/ios/prefix/include/boost/numeric/ublas/vector.hpp:21:
In file included from /Users/arunrajagopalan/work/boost_iOS/ios/prefix/include/boost/numeric/ublas/storage.hpp:25:
In file included from /Users/arunrajagopalan/work/boost_iOS/ios/prefix/include/boost/numeric/ublas/exception.hpp:19:
In file included from /Users/arunrajagopalan/work/boost_iOS/ios/prefix/include/boost/numeric/ublas/detail/config.hpp:299:
/Users/arunrajagopalan/work/boost_iOS/ios/prefix/include/boost/numeric/ublas/fwd.hpp:51:14: error: declaration of anonymous class must be a definition
template
^
/Users/arunrajagopalan/work/boost_iOS/ios/prefix/include/boost/numeric/ublas/fwd.hpp:52:28: error: expected template parameter
class vector_expression;
^
/Users/arunrajagopalan/work/boost_iOS/ios/prefix/include/boost/numeric/ublas/fwd.hpp:52:28: error: expected ',' or '>' in template-parameter-list
/Users/arunrajagopalan/work/boost_iOS/ios/prefix/include/boost/numeric/ublas/fwd.hpp:52:28: warning: declaration does not declare anything [-Wmissing-declarations]
class vector_expression;
^
/Users/arunrajagopalan/work/boost_iOS/ios/prefix/include/boost/numeric/ublas/fwd.hpp:56:14: error: declaration of anonymous class must be a definition
template
^

@arunrajagopalan

This comment has been minimized.

Copy link

arunrajagopalan commented Jan 2, 2016

It seems including boost before including any other headers resolved the issue. I don't know why

@maholloway

This comment has been minimized.

Copy link

maholloway commented Mar 11, 2016

This doesn't seem to work when trying to build boost.locale with ICU.

icu install is in /usr/local

bootstraps and builds just fine with "./boostrap --with-icu=/usr/local;./b2 --with-locale -sICU_PATH=/usr/local stage"

using the script I just get the "Boost.Locale needs either iconv or ICU library to be built." error.

Passing "-I/usr/local/include -I/usr/local/include -L/usr/local/lib" to user-config.jam inside the updateBoost function and adding --with-locale -sICU_PATH=/usr/local to the ./b2 commandline in buildBoost function doesn't fix the issue.

Anybody see the issue?

@dmigous

This comment has been minimized.

Copy link

dmigous commented Apr 27, 2016

vagrant@d64fca3aa1a0:/vagrant/base/boost_1_55_0$ ./bjam -j16 --build-dir=iphone-build --stagedir=iphone-build/stage --prefix=./build-tmp toolset=darwin architecture=arm target-os=iphone macosx-version=iphone-7.1 define=_LITTLE_ENDIAN link=static stage
sh: 1: /usr/bin/sw_vers: not found
link.jam: No such file or directory
/vagrant/base/boost_1_55_0/tools/build/v2/build/feature.jam:493: in validate-value-string from module feature
error: "iphone-7.1" is not a known value of feature <macosx-version>
error: legal values:

getting error: "iphone-7.1" is not a known value of feature <macosx-version> error. Maybe someone can help?

@faithfracture

This comment has been minimized.

Copy link
Owner Author

faithfracture commented Apr 28, 2016

Couple things:

  1. What parameters (if any) are you running the script with?
  2. Are you using the correct version of the script? This version of the script doesn't work with versions of boost prior to 1.56.
  3. Do you have the iOS 7.1 SDK installed?
  4. What is the output you get at the very beginning when you run the script?
    It should look something like this:
BUILD_IOS:           YES
BUILD_OSX:           YES
BOOST_VERSION:       1.58.0
IOS_SDK_VERSION:     9.3
MIN_IOS_VERSION:     8.0
OSX_SDK_VERSION:     10.11
MIN_OSX_VERSION:     10.10
OSX_ARCHS:           x86_64 (1)
BOOST_LIBS:          atomic chrono date_time exception filesystem program_options random signals system test thread
BOOST_SRC:           /Users/jordanbondo/Downloads/boostBuild/src/boost_1_58_0
IOSBUILDDIR:         /Users/jordanbondo/Downloads/boostBuild/ios/build
OSXBUILDDIR:         /Users/jordanbondo/Downloads/boostBuild/osx/build
PREFIXDIR:           /Users/jordanbondo/Downloads/boostBuild/ios/prefix
IOSFRAMEWORKDIR:     /Users/jordanbondo/Downloads/boostBuild/ios/framework
OSXFRAMEWORKDIR:     /Users/jordanbondo/Downloads/boostBuild/osx/framework
XCODE_ROOT:          /Applications/Xcode.app/Contents/Developer
@klodha

This comment has been minimized.

Copy link

klodha commented May 11, 2016

BUILD_IOS:           YES
BUILD_OSX:           YES
BOOST_VERSION:       1.60.0
IOS_SDK_VERSION:     8.4
OSX_SDK_VERSION:     10.10
MIN_IOS_VERSION:     8.0
BOOST_LIBS:          atomic chrono date_time exception filesystem program_options random signals system test thread
BOOST_SRC:           /Users/mgdev2/Desktop/Boost/src/boost_1_60_0
IOSBUILDDIR:         /Users/mgdev2/Desktop/Boost/ios/build
OSXBUILDDIR:         /Users/mgdev2/Desktop/Boost/osx/build
PREFIXDIR:           /Users/mgdev2/Desktop/Boost/ios/prefix
IOSFRAMEWORKDIR:     /Users/mgdev2/Desktop/Boost/ios/framework
OSXFRAMEWORKDIR:     /Users/mgdev2/Desktop/Boost/osx/framework
XCODE_ROOT:          /Applications/Xcode.app/Contents/Developer

I used this script to compile iOS & OSX framework. Everything compiled fine. OS X version works fine, but iOS version crashes in simulator, specially if I use a separate thread for async tcp client.

boost::thread bt(boost::bind(&boost::asio::io_service::run, &io_service)); cause it to crash in
boost::asio::async_read_until(socket_, input_buffer_, '\n', boost::bind(&TCPSocketClient::handle_read, this, _1));. However if I don't use thread and instead call io_service.run() to keep it in main thread itself, it works fine without any crash.

I tried searching for crash and somewhere read that it could be due to wrong compiler argument or different compilers. Any help?

@faithfracture

This comment has been minimized.

Copy link
Owner Author

faithfracture commented May 18, 2016

I use async_read_until in my own project and I do not have this issue. If it is a bad compiler argument, I don't know what it would be. The settings in this script are exactly the ones I use to build boost for myself. I'd need a lot more information to help troubleshoot this. Sorry.

@EspenNaess

This comment has been minimized.

Copy link

EspenNaess commented Jul 12, 2016

Seems like I can't build with the option BOOST_LIBS="asio system". I get this message, among others;

error: wrong library name 'asio' in the --with- option.

@blloyd75

This comment has been minimized.

Copy link

blloyd75 commented Aug 2, 2016

In response to EspenNaess, BOOST_LIBS can't reference header only "libraries", since there isn't a library to create for those. So BOOST_LIBS="asio system" can't figure out what to create for asio, because there is no asio library to create.

@Athenstean

This comment has been minimized.

Copy link

Athenstean commented Aug 15, 2016

I'm also trying to compile "locale" for iOS (but with iconv) and the problem seems to be that all of the "detection" modes do not work. If one adds locale to the list of libraries that shall be compiled, runs it and then checks iphone-build/boost/bin.v2/config.log one find's that boost tries to compile has_iconv.cpp (and some other test programs) and fails to compile it NOT because iconv isn't available but BECAUSE something removes the compiler path & name and it tries to execute "-ftemplate-depth-128 ..." (so only the parameters). My guess is it has to do with adding the entries into the user-config.jam but I have spent a couple of hours and couldn't really figure out the syntax... anyone got an idea?

This detection-compilation-problem exists in all other (older) variants of this script that I found...

@faithfracture

This comment has been minimized.

Copy link
Owner Author

faithfracture commented Aug 24, 2016

ATTENTION:
I have moved this script to an actual github repository. This will allow you all to create issues, make requests,
etc., without me having to remember to check this gist. It also means I will get emails when issues / questions are created.
It will also make it easier (hopefully) to track versioning.

The latest version there has been updated to build for tvOS (along with some other changes).

The new repository is located here:
https://github.com/faithfracture/Apple-Boost-BuildScript

@Dekwin

This comment has been minimized.

Copy link

Dekwin commented Jan 16, 2018

thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.