beginner to use assimp in ios - ios

I want to use Assimp in my upcoming ios project but having hard time to make it work. I followed the instructions from this:
How to build ASSIMP Library for iOS (Device and Simulator) with boost-library?
But Terminal keep telling me this:
rm: CMakeCache.txt: No such file or directory
/Users/hengchinsoon/Desktop/assimp/port/iOS/build_ios.sh: line 40: cmake: command not found
Building armv6 library
make: *** No rule to make target `clean'. Stop.
make: *** No rule to make target `assimp'. Stop.
cp: ./lib/libassimp.a: No such file or directory
rm: CMakeCache.txt: No such file or directory
/Users/hengchinsoon/Desktop/assimp/port/iOS/build_ios.sh: line 51: cmake: command not found
Building armv7 library
make: *** No rule to make target `clean'. Stop.
make: *** No rule to make target `assimp'. Stop.
cp: ./lib/libassimp.a: No such file or directory
rm: CMakeCache.txt: No such file or directory
/Users/hengchinsoon/Desktop/assimp/port/iOS/build_ios.sh: line 62: cmake: command not found
Building i386 library
make: *** No rule to make target `clean'. Stop.
make: *** No rule to make target `assimp'. Stop.
cp: ./lib/libassimp.a: No such file or directory
rm: ./lib/libassimp.a: No such file or directory
So I checked the assimp root folder and found out that there isn't any lib folder(which from the github descriptions, that is for windows usage). So i just made lib folder and try again. But still not working.
Can anybody share with me which part I did wrongly? Thanks!
Say if I successfully install whatever I need to install, then how to really use the library?
Should I copy the lib/ios/ folder into my ios projects?
What I want to do is to import some .blend files then I can experiment on the shader and other cool stuffs.
I am decent ios developer and have basic understanding of OpenGL ES. Somehow the Assimp document confused me about what it does. I am not so sure if I don't understand Assimp at the core concept level or at the programming level. But I am still convinced that it is very flexible and powerful.
Thanks for helping.

I'm guessing that you are using the "buil_ios.sh" script, in that script there are a few errors.
You should first download Cmake from : Cmake Download
Install Cmake and then do the following.
First of all, I think that besides that output you are getting some message that tells you that some options that you put in the Cmake are not being used. That's because in the script the name of some vars are not well written.
Besides this, you should change the CMakeLists.txt file so you don't get an error while you try to build the library:
Define here the needed parameters
set (ASSIMP_SV_REVISION 1023) <-- It should be less than 1024.
set (ASSIMP_VERSION ${ASSIMP_VERSION_MAJOR}) <-- here you will find some parameters like this. (parameter0).(parameter1)...
Mac OS doesn't like to put names using this nomenclature: parameter0.parameter1.paramter.2.a I guess it's because of the '.'.
So after a long day I finally managed to build the library. Another options is to get the library compiled from the project openframeworks, the path it's this: "/addons/ofxAssimpModelLoader/libs/assimp/lib/ios/assimp.a"
Here you have a link to the library
There you can find the library already compiled for the arm6 arm7 and i386 architectures.
I'm going to put you the script modified here.
#!/bin/sh
# build.sh
#######################
# BUILD ASSIMP for iOS and iOS Simulator
#######################
BUILD_DIR="./lib/ios"
IOS_BASE_SDK="5.0"
IOS_DEPLOY_TGT="3.2"
setenv_all()
{
# Add internal libs
export CFLAGS="$CFLAGS"
export CPP="$DEVROOT/usr/bin/llvm-cpp-4.2"
export CXX="$DEVROOT/usr/bin/llvm-g++-4.2"
export CXXCPP="$DEVROOT/usr/bin/llvm-cpp-4.2"
export CC="$DEVROOT/usr/bin/llvm-gcc-4.2"
export LD=$DEVROOT/usr/bin/ld
export AR=$DEVROOT/usr/bin/ar
export AS=$DEVROOT/usr/bin/as
export NM=$DEVROOT/usr/bin/nm
export RANLIB=$DEVROOT/usr/bin/ranlib
export LDFLAGS="-L$SDKROOT/usr/lib/"
export CPPFLAGS=$CFLAGS
export CXXFLAGS=$CFLAGS
}
setenv_arm6()
{
unset DEVROOT SDKROOT CFLAGS CC LD CPP CXX AR AS NM CXXCPP RANLIB LDFLAGS CPPFLAGS CXXFLAGS
export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
export SDKROOT=$DEVROOT/SDKs/iPhoneOS$IOS_BASE_SDK.sdk
export CFLAGS="-arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT -miphoneos-version-min=$IOS_DEPLOY_TGT -I$SDKROOT/usr/include/"
setenv_all
rm CMakeCache.txt
cmake -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=./port/iOS/IPHONEOS_ARM6_TOOLCHAIN.cmake -DENABLE_BOOST_WORKAROUND=ON -DBUILD_STATIC_LIB=ON -DASSIMP_BUILD_STATIC_LIB=ON
}
setenv_arm7()
{
unset DEVROOT SDKROOT CFLAGS CC LD CPP CXX AR AS NM CXXCPP RANLIB LDFLAGS CPPFLAGS CXXFLAGS
export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
export SDKROOT=$DEVROOT/SDKs/iPhoneOS$IOS_BASE_SDK.sdk
export CFLAGS="-arch armv7 -pipe -no-cpp-precomp -isysroot $SDKROOT -miphoneos-version-min=$IOS_DEPLOY_TGT -I$SDKROOT/usr/include/"
setenv_all
rm CMakeCache.txt
cmake -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=./port/iOS/IPHONEOS_ARM7_TOOLCHAIN.cmake -DENABLE_BOOST_WORKAROUND=ON -DBUILD_STATIC_LIB=ON -DASSIMP_BUILD_STATIC_LIB=ON
}
setenv_i386()
{
unset DEVROOT SDKROOT CFLAGS CC LD CPP CXX AR AS NM CXXCPP RANLIB LDFLAGS CPPFLAGS CXXFLAGS
export DEVROOT=/Developer/Platforms/iPhoneSimulator.platform/Developer
export SDKROOT=$DEVROOT/SDKs/iPhoneSimulator$IOS_BASE_SDK.sdk
export CFLAGS="-arch i386 -pipe -no-cpp-precomp -isysroot $SDKROOT -miphoneos-version-min=$IOS_DEPLOY_TGT"
setenv_all
rm CMakeCache.txt
cmake -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=./port/iOS/IPHONEOS_i386_TOOLCHAIN.cmake -DENABLE_BOOST_WORKAROUND=ON -DBUILD_STATIC_LIB=ON -DASSIMP_BUILD_STATIC_LIB=ON
}
create_outdir()
{
for lib_i386 in `find $BUILD_DIR/i386 -name "lib*\.a"`; do
lib_arm6=`echo $lib_i386 | sed "s/i386/arm6/g"`
lib_arm7=`echo $lib_i386 | sed "s/i386/arm7/g"`
lib=`echo $lib_i386 | sed "s/i386\///g"`
echo 'Creating fat binary...'
lipo -arch armv6 $lib_arm6 -arch armv7 $lib_arm7 -arch i386 $lib_i386 -create -output $lib
done
echo 'Done! You will find the libaries and fat binary library in /lib/ios'
}
cd ../../
rm -rf $BUILD_DIR
mkdir -p $BUILD_DIR/arm6 $BUILD_DIR/arm7 $BUILD_DIR/i386
setenv_arm6
echo 'Building armv6 library'
make clean
make assimp -j 8 -l
cp ./lib/libassimp.a $BUILD_DIR/arm6/
setenv_arm7
echo 'Building armv7 library'
make clean
make assimp -j 8 -l
cp ./lib/libassimp.a $BUILD_DIR/arm7/
setenv_i386
echo 'Building i386 library'
make clean
make assimp -j 8 -l
cp ./lib/libassimp.a $BUILD_DIR/i386/
rm ./lib/libassimp.a
create_outdir

I read somewhere that an alternative to this is to use openframeworks since it already incorporate assimp lib.
http://www.openframeworks.cc/download/
look for ios version. and inside there is a folder contain example/ios/assimpExample/ folder would be a good starting point.
Have fun!:D

The boost root for me on Mac with the latest version of Homebrew is the following:
BOOST_ROOT=~/.homebrew/Cellar/boost/1.53.0
Your version of boost may be different, so the last folder will vary. But as of a recent homebrew version, Cellar gets install within the current user's home directory.

Related

Error building webrtc library for iOS

I've been trying to build webrtc for iOS following Google's directions at http://www.webrtc.org/native-code/ios (and related links). Although I recall that with similar steps I've been able to build it in the past this is no longer the case.
Here's the steps I did:
Download prerequisites:
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
$ export PATH=`pwd`/depot_tools:"$PATH"
Download repo:
$ export GYP_DEFINES="OS=ios"
$ fetch webrtc_ios
Prepare build:
$ cd webrtc/src
$ export GYP_DEFINES="build_with_libjingle=1 build_with_chromium=0 libjingle_objc=1"
$ export GYP_DEFINES="$GYP_DEFINES OS=ios target_arch=armv7"
$ export GYP_GENERATOR_FLAGS="output_dir=out_ios"
$ export GYP_CROSSCOMPILE=1
$ gclient runhooks
Build:
$ ninja -C out_ios/Debug-iphoneos AppRTCDemo
Everything is ok, until the last command that fails with /bin/sh: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc: No such file or directory:
ninja: Entering directory `out_ios/Debug-iphoneos'
[3/1664] CC obj/chromium/src/third_party/boringssl/src/crypto/bio/boringssl.bio_mem.o
FAILED: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -MMD -MF obj/chromium/src/third_party/boringssl/src/crypto/bio/boringssl.bio_mem.o.d -DV8_DEPRECATION_WARNINGS -DCLD_VERSION=2 -DDISABLE_NACL -DCHROMIUM_BUILD -DCR_CLANG_REVISION=247874-1 -DUSE_LIBJPEG_TURBO=1 -DENABLE_CONFIGURATION_POLICY -DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE -DDONT_EMBED_BUILD_METADATA -DFIELDTRIAL_TESTING_ENABLED -DDISABLE_FTP_SUPPORT=1 -DV8_USE_EXTERNAL_STARTUP_DATA -DBORINGSSL_IMPLEMENTATION -DBORINGSSL_NO_STATIC_INITIALIZER -DOPENSSL_NO_ASM -DUSE_LIBPCI=1 -DUSE_OPENSSL=1 -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DWTF_USE_DYNAMIC_ANNOTATIONS=1 -Igen -I../../chromium/src/third_party/boringssl/src/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk -O0 -gdwarf-2 -fvisibility=hidden -Wnewline-eof -miphoneos-version-min=7.0 -arch arm64 -Wendif-labels -Wno-unused-parameter -Wno-missing-field-initializers -Wno-selector-type-mismatch -Wheader-hygiene -Wno-char-subscripts -Wno-unneeded-internal-declaration -Wno-covered-switch-default -Wstring-conversion -Wno-c++11-narrowing -Wno-deprecated-register -Wno-inconsistent-missing-override -Wno-shift-negative-value -Wno-bitfield-width -Wno-unused-function -Wno-unused-variable -m32 -arch i386 -pipe -no-cpp-precomp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk/usr/include/ -m32 -arch i386 -pipe -no-cpp-precomp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk/usr/include/ -std=c99 -Xclang -load -Xclang /Volumes/store/code/webrtc/src/third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.dylib -Xclang -add-plugin -Xclang find-bad-constructs -fcolor-diagnostics -fstack-protector-all -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -c ../../chromium/src/third_party/boringssl/src/crypto/bio/bio_mem.c -o obj/chromium/src/third_party/boringssl/src/crypto/bio/boringssl.bio_mem.o
/bin/sh: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc: No such file or directory
For some reason ninja thinks we are building for the Simulator, plus even if we did this would not be the right path to get gcc. Notice that my system has XCode 7 installed.
Any ideas what might be wrong or how I could work around this?
Best regards,
Antonis
A year ago I also wanted to build library using Google's instructions but I was unable to. Many errors occurred and I ended up googling for some build script. In the end I found this script. Make following steps and you will build it successfully:
Install Command Line Tools but pasting this command in terminal: xcode-select --install
Clone script: git clone https://github.com/lunastorm/webrtc-ios.git
Enter git repository in Terminal and run script with following command: make -j4 where j4 marks number of CPU cores (correct me if I'm wrong). This can take a while so prepare your self a cup of coffee
Build will fail for the first time but don't worry, just delete the folders which script downloaded. I will write which ones in edit
Find your code signing identity which is valid for building iOS apps. Type security find-identity in terminal. Pick one under Valid identities only
Open the global configuration file src/build/common.gypi and search for the text ‘CODE_SIGN_IDENTITY’. Replace ‘CODE_SIGN_IDENTITY[sdk=iphoneos*]‘: ‘iPhone Developer’ with your developer information i.e. ‘CODE_SIGN_IDENTITY[sdk=iphoneos*]‘: ‘iPhone Developer: Josip Bernat (2V3DKW6SDC)’
Run the script again using make -j4 and hopefully it will build you WebRTC.framework

./configure parameters to build C library for iOS

I'm writing an iOS application that runs an xml-rpc server. I'm using the C library for xml-rpc available here : http://xmlrpc-c.sourceforge.net/ . The library uses ./configure to generate the makefile according to the host architecture, and make, make install to build/install the library.
I need to use this library with my iOS application. I understand that XCode uses a completely different build system, and I'm new to iOS development, so I'm not quite sure how to tie in the library with my application. What options do I need to pass in with ./configure to compile the library for iOS architectures (I understand there are three targets, armv7, armv7s and i386)?
Thanks in advance.
Here are the configure script options for the simulator and device platforms.
Simulator (i386) :
$ ./configure --host=i386-apple-darwin --prefix <path_to_binaries> CFLAGS="-arch i386 -isysroot /Applications/XCode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/ -miphoneos-version-min=4.0 --disable-cplusplus
$ make
$ make install
iOS device (arm) : this is a bit trickier, and there's an unresolved issue with this, but here are the general steps:
$ ./configure --host=arm-apple-darwin --prefix <path_to_binaries> CFLAGS="-arch armv7s -isysroot /Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk -miphoneos-version-min=4.0" --disable-curl-client --disable-cplusplus LDFLAGS='-arch armv7s -miphoneos-version-min=4.0 -isysroot /Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk’
$ make
Notes specific to this library : We need to build gennmtab against x86, since it defines the symbol table and is to be run on the machine compiling the program - run the following commands (starting from the base xmlrpc-xx.xxx directory)
$ cd lib/expat/gennmtab/
$ rm gennmtab gennmtab.o
$ gcc -c gennmtab.c -o gennmtab.o -DNDEBUG -Wall -W -Wno-uninitialized -Wundef -Wimplicit -Winline -Wno-unknown-pragmas -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes -fno-common -g -O3 -D_THREAD -I/Users/sradhakrishnan/dev/xmlrpc-c-1.25.28 -Isrcdir/lib/util/include -I/Users/sradhakrishnan/dev/xmlrpc-c-1.25.28 -Isrcdir/lib/util/include
Now that gennmtab has been built against x86, continue with previous make, by running the following:
$ cd ../../../ (you are back in the base xmlrpc-xx.xxx directory)
$ make
$ make install

Installing ffmpeg ios libraries armv7, armv7s, i386 and universal on Mac with 10.8

How can I install latest ffmpeg ios libraries armv7, armv7s, i386 and universal on Mac with 10.8?
After a couple of days I have made step by step instructions for this install:
FFmpeg Build Instructions MAC 10.8 or better
Copy ffmpeg-2.0.tar.bz2 (https://ffmpeg.org/releases/ffmpeg-1.0.7.tar.bz2, https://ffmpeg.org/download.html) and Unzip to Documents folder
Make sure you have the latest Command Line Tools under Xcode >; Preferences >; Downloads >; Components
Install gas-preprocessor
Click on the ZIP icon to download https://github.com/mansr/gas-preprocessor.
Copy gas-preprocessor.pl to /usr/bin directory.
Change permission of gas-preprocessor.pl by setting the privilege to Read & Write for all.
Bug in xcrun starting in version 10.8
open terminal and paste in following command and press enter:
export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer/"
cd to ffmpeg-2 folder and paste in following command and press enter:
mkdir armv7
mkdir armv7s
mkdir i386
mkdir -p universal/lib
To config armv7s library paste in following command and press enter:
./configure --prefix=armv7s --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --enable-avresample --enable-cross-compile --sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk" --target-os=darwin --cc="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc" --extra-cflags="-arch armv7s -mfpu=neon -miphoneos-version-min=6.1" --extra-ldflags="-arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -miphoneos-version-min=6.1" --arch=arm --cpu=cortex-a9 --enable-pic
(Note same rule as above: if config fails go to
Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
and make sure that the sdk folder is iPhoneOS6.1.sdk, if not change
the config command to reflect iPhoneOSx.x.sdk and change all targets
to x.x)
To build and install armv7s library paste in following command and press enter:
make clean && make && make install
To config i386 (so simulator will work ) library paste in following command and press enter:
./configure --prefix=i386 --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --enable-avresample --enable-cross-compile --sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk" --target-os=darwin --cc="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc" --extra-cflags="-arch i386" --extra-ldflags="-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk" --arch=i386 --cpu=i386 --enable-pic --disable-asm
(Note: this is not the same command as the previous two config
commands, if you just arrow up to them this will fail)
To build and install i386 library paste in following command and press enter:
make clean && make && make install
To make universal library ( which is the library added to xcode ) paste in following command and press enter:
cd armv7/lib
for file in *.a
do
cd ../..
xcrun -sdk iphoneos lipo -output universal/lib/$file -create -arch armv7 armv7/lib/$file -arch armv7s armv7s/lib/$file -arch i386 i386/lib/$file
echo "Universal $file created."
cd -
done
cd ../..
Support universal ffmpeg library for iOS7 and XCode5:
Make sure you have the latest Command Line Tools under Xcode >; Preferences >; Downloads >; Components
Install gas-preprocessor
Click on the ZIP icon to download https://github.com/mansr/gas-preprocessor.
Copy gas-preprocessor.pl to /usr/bin directory.
Change permission of gas-preprocessor.pl by setting the privilege to Read & Write for all.
Download my shell script from: https://gist.github.com/m1entus/6983547
Run sh build-ffmpeg.sh.
I needed arm64 support and this script worked for me: https://github.com/kewlbear/FFmpeg-iOS-build-script
Use
./build-ffmpeg.sh arm64 x86_64
for iOS 64-bit and simulator architecture. Then copy the contents in the "fat" directory into your Xcode project.
The only modification I made to the script was uncommenting this line:
CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-avresample"
to compile the libavresample library.
Edit: It's not working with armv7 and armv7s however, using iOS 7.1 SDK. If I find a solution I'll post here.
For building ffmpeg iOS libraries you can use this little scripts.
Download ffmpeg source
Download https://github.com/wang-bin/build_ffmpeg
Open terminal and run export FFSRC=/path/to/ffmpeg
Goto build_ffmpeg folder and run: ./ios.sh
After successful building, result will be in sdk-ios folder
Add include folder and lib folder in your Xcode project

Building FFTW 3.3.3 for iPhone

I want to build FFTW library for iPhone and use this script:
#!/bin/bash
export SDKVER="6.0"
export DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer"
export SDKROOT="$DEVROOT/SDKs/iPhoneOS$SDKVER.sdk"
export CFLAGS="$CPPFLAGS -isysroot $SDKROOT"
export LDFLAGS="$CFLAGS -Wl,-syslibroot $SDKROOT"
export CC=$DEVROOT/usr/bin/arm-apple-darwin10-llvm-gcc-4.2
export LD=$DEVROOT/usr/bin/ld
export PREFIX="$HOME/Desktop/mylib"
./configure --prefix="$PREFIX" --enable-single --host=arm-apple-darwin
make
make install
Then I import libfftw3f.a and fftw3.h in Xcode in my project, link this library in Build Phases.
When I try to compile, Xcode gives me this warning:
ld: warning: ignoring file /Users/Adem/Desktop/mylib/lib/libfftw3f.a, file was built for archive which is not the architecture being linked (armv7s): /Users/Adem/Desktop/mylib/lib/libfftw3f.a
What am I doing wrong?
Try adding -arch armv7 to your CFLAGS (and hence also to your LDFLAGS)

Cross Compiling libogg for iOS

I've been trying to cross compile libogg for armv6, armv6 and i386 using the iOS 5.1 SDK in Mountain Lion. Libogg uses autoconf, and I've been having pretty similar issues with a few other libraries as well. I picked up a neat little cross-compiling script from here. I had to update it a bit to find the location of the SDK's.
GLOBAL_OUTDIR="`pwd`/dependencies"
mkdir -p $GLOBAL_OUTDIR/include $GLOBAL_OUTDIR/lib
OUTDIR="./outdir"
OGG_LIB="`pwd`/libogg-1.3.0"
IOS_BASE_SDK="5.1"
IOS_DEPLOY_TGT="3.2"
setenv_all()
{
# Add internal libs
export CFLAGS="$CFLAGS -I$GLOBAL_OUTDIR/include -L$GLOBAL_OUTDIR/lib"
export CXX="$DEVROOT/usr/bin/llvm-g++-4.2"
export CC="$DEVROOT/usr/bin/llvm-gcc-4.2"
export LD=$DEVROOT/usr/bin/ld
export AR=$DEVROOT/usr/bin/ar
export AS=$DEVROOT/usr/bin/as
export NM=$DEVROOT/usr/bin/nm
export RANLIB=$DEVROOT/usr/bin/ranlib
export LDFLAGS="-L$SDKROOT/usr/lib/"
export CPPFLAGS=$CFLAGS
export CXXFLAGS=$CFLAGS
}
setenv_arm6()
{
unset DEVROOT SDKROOT CFLAGS CC LD CPP CXX AR AS NM CXXCPP RANLIB LDFLAGS CPPFLAGS CXXFLAGS
export DEVROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
export SDKROOT=$DEVROOT/SDKs/iPhoneOS$IOS_BASE_SDK.sdk
export CFLAGS="-arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT -miphoneos-version-min=$IOS_DEPLOY_TGT -I$SDKROOT/usr/include/"
setenv_all
}
setenv_arm7()
{
unset DEVROOT SDKROOT CFLAGS CC LD CPP CXX AR AS NM CXXCPP RANLIB LDFLAGS CPPFLAGS CXXFLAGS
export DEVROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
export SDKROOT=$DEVROOT/SDKs/iPhoneOS$IOS_BASE_SDK.sdk
export CFLAGS="-arch armv7 -pipe -no-cpp-precomp -isysroot $SDKROOT -miphoneos-version-min=$IOS_DEPLOY_TGT -I$SDKROOT/usr/include/"
setenv_all
}
setenv_i386()
{
unset DEVROOT SDKROOT CFLAGS CC LD CPP CXX AR AS NM CXXCPP RANLIB LDFLAGS CPPFLAGS CXXFLAGS
export DEVROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer
export SDKROOT=$DEVROOT/SDKs/iPhoneSimulator$IOS_BASE_SDK.sdk
export CFLAGS="-arch i386 -pipe -no-cpp-precomp -isysroot $SDKROOT -miphoneos-version-min=$IOS_DEPLOY_TGT"
setenv_all
}
create_outdir_lipo()
{
for lib_i386 in `find $LOCAL_OUTDIR/i386 -name "lib*\.a"`; do
lib_arm6=`echo $lib_i386 | sed "s/i386/arm6/g"`
lib_arm7=`echo $lib_i386 | sed "s/i386/arm7/g"`
lib=`echo $lib_i386 | sed "s/i386\///g"`
lipo -arch armv6 $lib_arm6 -arch armv7 $lib_arm7 -arch i386 $lib_i386 -create -output $lib
done
}
merge_libfiles()
{
DIR=$1
LIBNAME=$2
cd $DIR
for i in `find . -name "lib*.a"`; do
$AR -x $i
done
$AR -r $LIBNAME *.o
rm -rf *.o __*
cd -
}
And then to build the ogg library.
## libogg
cd $OGG_LIB
rm -rf $OUTPUT_DIR
mkdir -p $OUTDIR/arm6 $OUTDIR/arm7 $OUTDIR/i386
## Build for armv6
make clean 2> /dev/null
make distclean 2> /dev/null
setenv_arm6
./configure --host=arm-apple-darwin6 --enable-shared=no
make
cp /src/.libs/libogg.a $OUTDIR/arm6
## Build for armv7
make clean 2> /dev/null
make distclean 2> /dev/null
setenv_arm7
./configure --host=arm-apple-darwin7 --enable-shared=no
make
cp src/.libs/libogg.a $OUTDIR/arm7
## Build for iPhone simulator
make clean 2> /dev/null
setenv_i386
./configure
make -j4
cp src/.libs/libogg.a $OUTDIR/i386
## Stich it altogether in a fat .a file.
create_outdir_lipo
Anyway, when building armv6 and armv7, configure finds the compiler's and sdk's okay , and the compiling stage goes off without a hitch. But they both fail to link. The armv7 build spits out the error.
ld: in section __TEXT,__text reloc 1: unknown relocation type 9 for architecture armv7 collect2: ld returned 1 exit status
And when I test the output binary with lipo :
$ lipo -info libogg.a
lipo: archive with no architecture specification: libogg.a (can't determine architecture for it)
What is strange is i386 seems to compile perfectly, (I've tried it in the simulator and all is okay).
Any suggestions on what I can do to try and fix this, or a least where I should start looking. Sorry for the massive code dumps, and thanks.
I was able to solve this by setting the optimization level on the compile to -O3 instead of -O4. With -O4 the files output do not seem to be recognizable to lipo (and even file reports them as data instead of Mach-O object arm).
Update: It seems quite a few people are encountering difficulty compiling Ogg Vorbis. I have made my build available. See: Precompiled Ogg Vorbis Libraries for iOS.

Resources