Monday, November 28, 2016

How to build c++ libraries (boost & QuantLib) for iOS XCode 8

(1) Download boost 1.62.0 and extract source
shell script    Select all
# download boost source cd $HOME/Downloads curl -O https://nchc.dl.sourceforge.net/project/boost/boost/1.62.0/boost_1_62_0.tar.bz2 tar xjvf boost_1_62_0.tar.bz2 cd boost_1_62_0 # create the following user-config.jam at ~/Downloads/boost_1_62_0/tools/build/src/ cat > tools/build/src/user-config.jam << 'EOF' # ------------------ # darwin iphone configuration. # ------------------ local XCODE_ROOT = /Applications/Xcode.app/Contents/Developer ; using darwin : armv7 : $(XCODE_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ : <striper>$(XCODE_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip <root>$(XCODE_ROOT)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk <compileflags>"-isysroot $(XCODE_ROOT)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk" <compileflags>"-arch armv7" <compileflags>-fexceptions <compileflags>-frtti <compileflags>-fpic <compileflags>-DBOOST_SP_USE_SPINLOCK <compileflags>-std=c++11 <compileflags>-stdlib=libc++ <compileflags>-miphoneos-version-min=7.0 <compileflags>-fvisibility=hidden <compileflags>-fvisibility-inlines-hidden <compileflags>-O2 <compileflags>-g <compileflags>-Os <compileflags>-Wno-long-long <compileflags>-Wno-missing-field-initializers <compileflags>-Wno-unused-variable <linkflags>-stdlib=libc++ <architecture>arm <address-model>32 <target-os>iphone ; using darwin : armv7s : $(XCODE_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ : <striper>$(XCODE_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip <root>$(XCODE_ROOT)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk <compileflags>"-isysroot $(XCODE_ROOT)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk" <compileflags>"-arch armv7s" <compileflags>-fexceptions <compileflags>-frtti <compileflags>-fpic <compileflags>-DBOOST_SP_USE_SPINLOCK <compileflags>-std=c++11 <compileflags>-stdlib=libc++ <compileflags>-miphoneos-version-min=7.0 <compileflags>-fvisibility=hidden <compileflags>-fvisibility-inlines-hidden <compileflags>-O2 <compileflags>-g <compileflags>-Os <compileflags>-Wno-long-long <compileflags>-Wno-missing-field-initializers <compileflags>-Wno-unused-variable <linkflags>-stdlib=libc++ <architecture>arm <address-model>32 <target-os>iphone ; using darwin : arm64 : $(XCODE_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ : <striper>$(XCODE_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip <root>$(XCODE_ROOT)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk <compileflags>"-isysroot $(XCODE_ROOT)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk" <compileflags>"-arch arm64" <compileflags>-fexceptions <compileflags>-frtti <compileflags>-fpic <compileflags>-DBOOST_SP_USE_SPINLOCK <compileflags>-std=c++11 <compileflags>-stdlib=libc++ <compileflags>-miphoneos-version-min=7.0 <compileflags>-fvisibility=hidden <compileflags>-fvisibility-inlines-hidden <compileflags>-O2 <compileflags>-g <compileflags>-Os <compileflags>-Wno-long-long <compileflags>-Wno-missing-field-initializers <compileflags>-Wno-unused-variable <linkflags>-stdlib=libc++ <architecture>arm <address-model>64 <target-os>iphone ; using darwin : i386 : $(XCODE_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ : <striper>$(XCODE_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip <root>$(XCODE_ROOT)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk <compileflags>"-arch i386" <compileflags>"-isysroot $(XCODE_ROOT)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk" <compileflags>-fexceptions <compileflags>-frtti <compileflags>-fpic <compileflags>-DBOOST_SP_USE_SPINLOCK <compileflags>-std=c++11 <compileflags>-stdlib=libc++ <compileflags>-miphoneos-version-min=7.0 <compileflags>-fvisibility=hidden <compileflags>-fvisibility-inlines-hidden <compileflags>-O2 <compileflags>-g <compileflags>-Os <compileflags>-Wno-long-long <compileflags>-Wno-missing-field-initializers <compileflags>-Wno-unused-variable <linkflags>-stdlib=libc++ <architecture>x86 <address-model>32 <target-os>iphone ; using darwin : x86_64 : $(XCODE_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ : <striper>$(XCODE_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip <root>$(XCODE_ROOT)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk <compileflags>"-arch x86_64" <compileflags>"-isysroot $(XCODE_ROOT)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk" <compileflags>-fexceptions <compileflags>-frtti <compileflags>-fpic <compileflags>-DBOOST_SP_USE_SPINLOCK <compileflags>-std=c++11 <compileflags>-stdlib=libc++ <compileflags>-miphoneos-version-min=7.0 <compileflags>-fvisibility=hidden <compileflags>-fvisibility-inlines-hidden <compileflags>-O2 <compileflags>-g <compileflags>-Os <compileflags>-Wno-long-long <compileflags>-Wno-missing-field-initializers <compileflags>-Wno-unused-variable <linkflags>-stdlib=libc++ <architecture>x86 <address-model>64 <target-os>iphone ; EOF


(2) patch boost_1_62_0/tools/build/src/tools/darwin.jam
~/Downloads/boost_1_62_0/tools/build/src/tools/darwin.jam    Select all
#change from case arm : { if $(instruction-set) { options = -arch$(_)$(instruction-set) ; } else { options = -arch arm ; } } #to case arm : { if $(instruction-set) { options = -arch$(_)$(instruction-set) ; } else if $(address-model) = 64 { options = -arch arm64 ; } else { options = -arch arm ; } }


(3) build boost libraries for iOS
shell script    Select all
# bootstrap cd $HOME/Downloads/boost_1_62_0 ./bootstrap.sh --with-libraries=atomic,chrono,date_time,exception,filesystem,graph,iostreams,math,program_options,random,regex,serialization,signals,system,test,thread,wave # clean and build for iOS, j option is num of cores x 1.5 rm -fr ios-build ./b2 -j6 --build-dir=ios-build --stagedir=ios-build/armv7 toolset=darwin-armv7 architecture=arm instruction-set=armv7 address-model=32 target-os=iphone threading=multi link=static stage ./b2 -j6 --build-dir=ios-build --stagedir=ios-build/armv7s toolset=darwin-armv7s architecture=arm instruction-set=armv7s address-model=32 target-os=iphone threading=multi link=static stage ./b2 -j6 --build-dir=ios-build --stagedir=ios-build/arm64 toolset=darwin-arm64 architecture=arm address-model=64 target-os=iphone threading=multi link=static stage ./b2 -j6 --build-dir=ios-build --stagedir=ios-build/i386 toolset=darwin-i386 architecture=x86 address-model=32 target-os=iphone threading=multi link=static stage ./b2 -j6 --build-dir=ios-build --stagedir=ios-build/x86_64 toolset=darwin-x86_64 architecture=x86 address-model=64 target-os=iphone threading=multi link=static stage # create libboost.a archive for each architecture cd $HOME/Downloads/boost_1_62_0 cd ios-build xcrun --sdk iphoneos ar crus armv7/libboost.a boost/bin.v2/libs/*/build/darwin-armv7/release/instruction-set-armv7/link-static/target-os-iphone/threading-multi/*/*.o xcrun --sdk iphoneos ar crus armv7s/libboost.a boost/bin.v2/libs/*/build/darwin-armv7s/release/instruction-set-armv7s/link-static/target-os-iphone/threading-multi/*/*.o xcrun --sdk iphoneos ar crus arm64/libboost.a boost/bin.v2/libs/*/build/darwin-arm64/release/link-static/target-os-iphone/threading-multi/*/*.o xcrun --sdk iphoneos ar crus i386/libboost.a boost/bin.v2/libs/*/build/darwin-i386/release/link-static/target-os-iphone/threading-multi/*/*.o xcrun --sdk iphoneos ar crus x86_64/libboost.a boost/bin.v2/libs/*/build/darwin-x86_64/release/link-static/target-os-iphone/threading-multi/*/*.o # create FAT libboost.a archive mkdir -p lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo \ -arch armv7 "armv7/libboost.a" \ -arch armv7s "armv7s/libboost.a" \ -arch arm64 "arm64/libboost.a" \ -arch i386 "i386/libboost.a" \ -arch x86_64 "x86_64/libboost.a" \ -output "lib/libboost.a" \ -create # create link for include folder mkdir include cd include ln -s ../../boost .


(4) Create boost Framework for iOS
shell script    Select all
cd $HOME/Downloads/boost_1_62_0 cd ios-build #Create the following shell script for build-boostframework.sh cat > build-boostframework.sh << 'boostFrameworkEOF' #!/bin/bash # build-boostframework.sh VERSION_TYPE=Alpha FRAMEWORK_NAME=boost FRAMEWORK_VERSION=A FRAMEWORKDIR=. FRAMEWORK_CURRENT_VERSION=1.62.0 FRAMEWORK_COMPATIBILITY_VERSION=1.62.0 FRAMEWORK_BUNDLE=${FRAMEWORKDIR}/${FRAMEWORK_NAME}.framework rm -rf ${FRAMEWORK_BUNDLE} 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 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 "Framework: Lipoing library into ${FRAMEWORK_INSTALL_NAME}" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo \ -arch armv7 "armv7/libboost.a" \ -arch armv7s "armv7s/libboost.a" \ -arch arm64 "arm64/libboost.a" \ -arch i386 "i386/libboost.a" \ -arch x86_64 "x86_64/libboost.a" \ -output "${FRAMEWORK_INSTALL_NAME}" \ -create echo "Framework: Copying includes..." cp -r include/${FRAMEWORK_NAME}/* ${FRAMEWORK_BUNDLE}/Headers/ cat > ${FRAMEWORK_BUNDLE}/Resources/Info.plist <<InfoplistEOF <?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>${FRAMEWORK_NAME}.org</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> InfoplistEOF echo "Done: ${FRAMEWORK_BUNDLE}" boostFrameworkEOF # build framework sh build-boostframework.sh


(5) Download and build QuantLib 1.9 for iOS
shell script    Select all
# download quantlib source cd $HOME/Downloads curl -O https://jaist.dl.sourceforge.net/project/quantlib/QuantLib/1.9/QuantLib-1.9.tar.gz tar xzvf QuantLib-1.9.tar.gz cd QuantLib-1.9 #Create the following shell script for armv7 cat > ~/Downloads/QuantLib-1.9/build-armv7.sh << 'armv7EOF' #!/bin/bash # build-armv7.sh BUILD_DIR=ios-build mkdir -p ${BUILD_DIR} INSTALL_DIR="`pwd`/${BUILD_DIR}" YOUR_PATH_TO_INSTALL_DIR="`cd "${INSTALL_DIR}";pwd`" XCODE_ROOT=/Applications/Xcode.app/Contents/Developer YOUR_TOOLCHAIN=${XCODE_ROOT}/Toolchains/XcodeDefault.xctoolchain/usr/bin sysroot=${XCODE_ROOT}/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk export CC=${YOUR_TOOLCHAIN}/clang export CXX=${YOUR_TOOLCHAIN}/clang++ export CPP=${YOUR_TOOLCHAIN}/cpp export AR=${YOUR_TOOLCHAIN}/ar export RANLIB=${YOUR_TOOLCHAIN}/ranlib export LD=${YOUR_TOOLCHAIN}/ld export CFLAGS="-arch armv7 -std=c99 -miphoneos-version-min=7.0 -isysroot ${sysroot}" export CXXFLAGS="-arch armv7 -fexceptions -frtti -fpic -std=c++11 -stdlib=libc++ -miphoneos-version-min=7.0 -O2 -g -fvisibility=hidden -fvisibility-inlines-hidden -Os -isysroot ${sysroot}" export LDFLAGS="-stdlib=libc++" boost_include="`cd "../boost_1_62_0/ios-build/include";pwd`" boost_lib="`cd "../boost_1_62_0/ios-build/armv7/lib";pwd`" make distclean ./configure --prefix=/armv7 --host=arm-apple-darwin10 --with-sysroot=${sysroot} --with-boost-include=${boost_include} --with-boost-lib=${boost_lib} --enable-static --enable-shared=no --disable-examples make -j6 make install DESTDIR=${YOUR_PATH_TO_INSTALL_DIR} armv7EOF #Create the following shell script for armv7s cat > ~/Downloads/QuantLib-1.9/build-armv7s.sh << 'armv7sEOF' #!/bin/bash # build-armv7s.sh BUILD_DIR=ios-build mkdir -p ${BUILD_DIR} INSTALL_DIR="`pwd`/${BUILD_DIR}" YOUR_PATH_TO_INSTALL_DIR="`cd "${INSTALL_DIR}";pwd`" XCODE_ROOT=/Applications/Xcode.app/Contents/Developer YOUR_TOOLCHAIN=${XCODE_ROOT}/Toolchains/XcodeDefault.xctoolchain/usr/bin sysroot=${XCODE_ROOT}/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk export CC=${YOUR_TOOLCHAIN}/clang export CXX=${YOUR_TOOLCHAIN}/clang++ export CPP=${YOUR_TOOLCHAIN}/cpp export AR=${YOUR_TOOLCHAIN}/ar export RANLIB=${YOUR_TOOLCHAIN}/ranlib export LD=${YOUR_TOOLCHAIN}/ld export CFLAGS="-arch armv7s -std=c99 -miphoneos-version-min=7.0 -isysroot ${sysroot}" export CXXFLAGS="-arch armv7s -fexceptions -frtti -fpic -std=c++11 -stdlib=libc++ -miphoneos-version-min=7.0 -O2 -g -fvisibility=hidden -fvisibility-inlines-hidden -Os -isysroot ${sysroot}" export LDFLAGS="-stdlib=libc++" boost_include="`cd "../boost_1_62_0/ios-build/include";pwd`" boost_lib="`cd "../boost_1_62_0/ios-build/armv7s/lib";pwd`" make distclean ./configure --prefix=/armv7s --host=arm-apple-darwin10 --with-sysroot=${sysroot} --with-boost-include=${boost_include} --with-boost-lib=${boost_lib} --enable-static --enable-shared=no --disable-examples make -j6 make install DESTDIR=${YOUR_PATH_TO_INSTALL_DIR} armv7sEOF #Create the following shell script for arm64 cat > ~/Downloads/QuantLib-1.9/build-arm64.sh << 'arm64EOF' #!/bin/bash # build-arm64.sh BUILD_DIR=ios-build mkdir -p ${BUILD_DIR} INSTALL_DIR="`pwd`/${BUILD_DIR}" YOUR_PATH_TO_INSTALL_DIR="`cd "${INSTALL_DIR}";pwd`" XCODE_ROOT=/Applications/Xcode.app/Contents/Developer YOUR_TOOLCHAIN=${XCODE_ROOT}/Toolchains/XcodeDefault.xctoolchain/usr/bin sysroot=${XCODE_ROOT}/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk export CC=${YOUR_TOOLCHAIN}/clang export CXX=${YOUR_TOOLCHAIN}/clang++ export CPP=${YOUR_TOOLCHAIN}/cpp export AR=${YOUR_TOOLCHAIN}/ar export RANLIB=${YOUR_TOOLCHAIN}/ranlib export LD=${YOUR_TOOLCHAIN}/ld export CFLAGS="-arch arm64 -std=c99 -miphoneos-version-min=7.0 -isysroot ${sysroot}" export CXXFLAGS="-arch arm64 -fexceptions -frtti -fpic -std=c++11 -stdlib=libc++ -miphoneos-version-min=7.0 -O2 -g -fvisibility=hidden -fvisibility-inlines-hidden -Os -isysroot ${sysroot}" export LDFLAGS="-stdlib=libc++" boost_include="`cd "../boost_1_62_0/ios-build/include";pwd`" boost_lib="`cd "../boost_1_62_0/ios-build/arm64/lib";pwd`" make distclean ./configure --prefix=/arm64 --host=arm-apple-darwin10 --with-sysroot=${sysroot} --with-boost-include=${boost_include} --with-boost-lib=${boost_lib} --enable-static --enable-shared=no --disable-examples make -j6 make install DESTDIR=${YOUR_PATH_TO_INSTALL_DIR} arm64EOF #Create the following shell script for i386 cat > ~/Downloads/QuantLib-1.9/build-i386.sh << 'i386EOF' #!/bin/bash # build-i386.sh BUILD_DIR=ios-build mkdir -p ${BUILD_DIR} INSTALL_DIR="`pwd`/${BUILD_DIR}" YOUR_PATH_TO_INSTALL_DIR="`cd "${INSTALL_DIR}";pwd`" XCODE_ROOT=/Applications/Xcode.app/Contents/Developer YOUR_TOOLCHAIN=${XCODE_ROOT}/Toolchains/XcodeDefault.xctoolchain/usr/bin sysroot=${XCODE_ROOT}/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk export CC=${YOUR_TOOLCHAIN}/clang export CXX=${YOUR_TOOLCHAIN}/clang++ export CPP=${YOUR_TOOLCHAIN}/cpp export AR=${YOUR_TOOLCHAIN}/ar export RANLIB=${YOUR_TOOLCHAIN}/ranlib export LD=${YOUR_TOOLCHAIN}/ld export CFLAGS="-arch i386 -std=c99 -miphoneos-version-min=7.0 -isysroot ${sysroot}" export CXXFLAGS="-arch i386 -fexceptions -frtti -fpic -std=c++11 -stdlib=libc++ -miphoneos-version-min=7.0 -O2 -g -fvisibility=hidden -fvisibility-inlines-hidden -Os -isysroot ${sysroot}" export LDFLAGS="-stdlib=libc++" boost_include="`cd "../boost_1_62_0/ios-build/include";pwd`" boost_lib="`cd "../boost_1_62_0/ios-build/i386/lib";pwd`" make distclean ./configure --prefix=/i386 --host=i386-apple-darwin10 --with-sysroot=${sysroot} --with-boost-include=${boost_include} --with-boost-lib=${boost_lib} --enable-static --enable-shared=no --disable-examples make -j6 make install DESTDIR=${YOUR_PATH_TO_INSTALL_DIR} i386EOF #Create the following shell script for x86_64 cat > ~/Downloads/QuantLib-1.9/build-x86_64.sh << 'x86_64EOF' #!/bin/bash # build-x86_64.sh BUILD_DIR=ios-build mkdir -p ${BUILD_DIR} INSTALL_DIR="`pwd`/${BUILD_DIR}" YOUR_PATH_TO_INSTALL_DIR="`cd "${INSTALL_DIR}";pwd`" XCODE_ROOT=/Applications/Xcode.app/Contents/Developer YOUR_TOOLCHAIN=${XCODE_ROOT}/Toolchains/XcodeDefault.xctoolchain/usr/bin sysroot=${XCODE_ROOT}/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk export CC=${YOUR_TOOLCHAIN}/clang export CXX=${YOUR_TOOLCHAIN}/clang++ export CPP=${YOUR_TOOLCHAIN}/cpp export AR=${YOUR_TOOLCHAIN}/ar export RANLIB=${YOUR_TOOLCHAIN}/ranlib export LD=${YOUR_TOOLCHAIN}/ld export CFLAGS="-arch x86_64 -std=c99 -miphoneos-version-min=7.0 -isysroot ${sysroot}" export CXXFLAGS="-arch x86_64 -fexceptions -frtti -fpic -std=c++11 -stdlib=libc++ -miphoneos-version-min=7.0 -O2 -g -fvisibility=hidden -fvisibility-inlines-hidden -Os -isysroot ${sysroot}" export LDFLAGS="-stdlib=libc++" boost_include="`cd "../boost_1_62_0/ios-build/include";pwd`" boost_lib="`cd "../boost_1_62_0/ios-build/x86_64/lib";pwd`" make distclean ./configure --prefix=/x86_64 --host=x86_64-apple-darwin10 --with-sysroot=${sysroot} --with-boost-include=${boost_include} --with-boost-lib=${boost_lib} --enable-static --enable-shared=no --disable-examples make -j6 make install DESTDIR=${YOUR_PATH_TO_INSTALL_DIR} x86_64EOF #run shell scripts to clean and build for iOS cd $HOME/Downloads cd QuantLib-1.9 rm -fr ios-build sh build-armv7.sh sh build-armv7s.sh sh build-arm64.sh sh build-i386.sh sh build-x86_64.sh # create FAT libQuantLib.a archive cd $HOME/Downloads/QuantLib-1.9 cd ios-build mkdir -p lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo \ -arch armv7 "armv7/lib/libQuantLib.a" \ -arch armv7s "armv7s/lib/libQuantLib.a" \ -arch arm64 "arm64/lib/libQuantLib.a" \ -arch i386 "i386/lib/libQuantLib.a" \ -arch x86_64 "x86_64/lib/libQuantLib.a" \ -output "lib/libQuantLib.a" \ -create # create link for include folder mkdir include cd include ln -s ../arm64/include/ql .


(6) Create QuantLib Framework for iOS
shell script    Select all
cd $HOME/Downloads/QuantLib-1.9 cd ios-build #Create the following shell script for build-qlframework.sh cat > build-qlframework.sh << 'qlFrameworkEOF' #!/bin/bash # build-qlframework.sh VERSION_TYPE=Alpha FRAMEWORK_NAME=ql FRAMEWORK_VERSION=A FRAMEWORKDIR=. FRAMEWORK_CURRENT_VERSION=1.9 FRAMEWORK_COMPATIBILITY_VERSION=1.9 FRAMEWORK_BUNDLE=${FRAMEWORKDIR}/${FRAMEWORK_NAME}.framework rm -rf ${FRAMEWORK_BUNDLE} 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 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 "Framework: Lipoing library into ${FRAMEWORK_INSTALL_NAME}" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo \ -arch armv7 "armv7/lib/libQuantLib.a" \ -arch armv7s "armv7s/lib/libQuantLib.a" \ -arch arm64 "arm64/lib/libQuantLib.a" \ -arch i386 "i386/lib/libQuantLib.a" \ -arch x86_64 "x86_64/lib/libQuantLib.a" \ -output "${FRAMEWORK_INSTALL_NAME}" \ -create echo "Framework: Copying includes..." cp -r include/${FRAMEWORK_NAME}/* ${FRAMEWORK_BUNDLE}/Headers/ cat > ${FRAMEWORK_BUNDLE}/Resources/Info.plist <<InfoplistEOF <?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>quantlib.org</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> InfoplistEOF echo "Done: ${FRAMEWORK_BUNDLE}" qlFrameworkEOF # build framework sh build-qlframework.sh