Specfying the search path for a framework in Xcode [duplicate] - ios

I wrote C program that calculates the time step iterations of wavefunctions to solve the time depended Schrödinger equation.
At some step I need to do forward and backward Fast Fourier Transformations (FFT) for which I used the library kissfft.
(https://github.com/mborgerding/kissfft)
My programs structure is somewhat like this:
TDSE (working directory)
modules
include
scripts
test
inttest_analytical.c
kissfft
libkissfft-double.dylib
Now when I compile my inttest_analytical.c it works.
But when trying to run the executable afterwards I get the following error:
(base) user TDSE % ./inttest_analytical
dyld: Library not loaded: libkissfft-double.dylib
Referenced from: /Users/user/Documents/Uni/HU Berlin/Computational Physics 2/Project 3 - Time-dependet Schroedinger Equation/TDSE/./inttest_analytical
Reason: image not found
zsh: abort ./inttest_analytical
After running otool -L ./inttest_analytical I get
/inttest_analytical:
libkissfft-double.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
As far as I understand from reading about this in other questions on google searches, libkissfft-double.dylib is a static library but I don't manage to tell gcc where to find the library. And the path it was given (by the compiler or linker?) is the working directory TDSE instead of TDSE/kissfft
For compilation I ran:
gcc -g -Wall -fPIC -I include -I kissff ./modules/wavefunction.c ./modules/integrator.c ./modules/geometry.c ./modules/linearalgebra.c ./modules/assert.c ./modules/hamiltonian.c ./modules/conjugategradient.c ./test/inttest_analytical.c -Lkissfft -lkissfft-double -o inttest_analytical
So I guess I am using the flags -L and -l wrong??
Thanks for any help.

I guess I'll use this question to write a canonical answer for all "image not found" issues.
1. The issue
Let's start with a minimal setup consisting of a main binary and a library, like so:
main.c:
#include <stdio.h>
extern int f(void);
int main(void)
{
printf("%u\n", f());
return 0;
}
xyz.c:
int f(void)
{
return 42;
}
command line:
% cc -Wall -O3 -shared -o libxyz.dylib xyz.c
% cc -Wall -O3 -o main main.c -L. -lxyz
This works. You can run ./main and it will print 42.
However, if you now create a folder lib, move libxyz.dylib there and recompile main like so:
% cc -Wall -O3 -o main main.c -Llib -lxyz
Then the compilation will still succeed, however launching it will not:
% ./main
dyld: Library not loaded: libxyz.dylib
Referenced from: /private/tmp/./main
Reason: image not found
But if you go back and recompile libxyz.dylib to the lib folder directly and then rebuild main, like so:
% cc -Wall -O3 -shared -o lib/libxyz.dylib xyz.c
% cc -Wall -O3 -o main main.c -Llib -lxyz
Then it will once again work. But just to illustrate, this is the error you get if you move libxyz.dylib once more:
% ./main
dyld: Library not loaded: lib/libxyz.dylib
Referenced from: /private/tmp/./main
Reason: image not found
Just to make things worse though, you can also produce this error without even moving the library: simply cd lib and invoke ../main.
Also note the difference to before, libxyz.dylib vs lib/libxyz.dylib. This brings us to the core of the issue.
2. The reason
On macOS, each shared library has an "install name", i.e. the path at which it is expected to be found at runtime. This path can take three forms:
Absolute, e.g. /usr/lib/libxyz.dylib.
Relative, e.g. lib/libxyz.dylib.
Magic, e.g. #rpath/libxyz.dylib.
This path is embedded in the Mach-O header of the library, via the LC_ID_DYLIB load command. It can be viewed with otool like so:
% otool -l /tmp/lib/libxyz.dylib | fgrep -B1 -A5 LC_ID_DYLIB
Load command 2
cmd LC_ID_DYLIB
cmdsize 48
name lib/libxyz.dylib (offset 24)
time stamp 1 Thu Jan 1 01:00:01 1970
current version 0.0.0
compatibility version 0.0.0
This load command is created by the linker, whose man page (man ld) tells us the following:
-install_name name
Sets an internal "install path" (LC_ID_DYLIB) in a dynamic library.
Any clients linked against the library will record that path as the
way dyld should locate this library. If this option is not specified,
then the -o path will be used. This option is also called
-dylib_install_name for compatibility.
This tells us the three steps of how install names work:
The linker embeds the name when the library is built.
The linker copies the name into binaries linking against that library when those are built.
Dyld uses that name to try and load the library.
This will obviously cause issues if libraries are moved, or aren't even being compiled with the install name matching the path at which they will end up.
3. The solution
The solution is to change the install name path. Where and how depends on your setup. You can change it by two means:
Recompile the library with the correct install name (either -Wl,-install_name,... or outright -o ...), then recompile the main binary to link against that.
Use install_name_tool. This is a bit more involved.
In either case, you need to decide what form of install name you want to use:
Absolute.
This is recommended for libraries in global paths, shared by all users. You can also use this to point to your user directory, but it's a bit ugly since you can't move the binaries around or distribute them to someone else.
Relative.
Being relative to your working directory means this is entirely unreliable.
Never use this. Just don't.
Magic.
There are three "special" tokens that go beyond absolute and relative paths:
#executable_path is the runtime directory of the main binary of the process. This is the simplest form, but only works if your libraries are only used in a single main binary.
#loader_path is the runtime directory of the binary depending on the library. I recommend not using this, as it breaks if you have two binaries in different folders that want to link to the same library.
#rpath is a list of runtime directories assembled from LC_RPATH load commands. This is a bit more complex, but it's the most flexible solution, since it can itself contain #executable_path and #loader_path.
Use of those allows you to build binaries that can be moved around freely, so long as they all retain their relative position.
For a full description of them, see man dyld.
With that out of the way, let's look at implementing the possible solutions. We have:
cc -Wl,-install_name,... to specify an install name at compile time.
install_name_tool -id ... to change the path embedded in a library.
install_name_tool -change old new to change the path embedded in a binary linking against a library.
3.1 Absolute paths
If you can recompile both the library and the main binary:
% cc -Wall -O3 -shared -o /tmp/lib/libxyz.dylib xyz.c
% cc -Wall -O3 -o main main.c -L/tmp/lib -lxyz
If you can only recompile the main binary:
% install_name_tool -id '/tmp/lib/libxyz.dylib' /tmp/lib/libxyz.dylib
% cc -Wall -O3 -o main main.c -L/tmp/lib -lxyz
If you cannot recompile either:
% install_name_tool -id '/tmp/lib/libxyz.dylib' /tmp/lib/libxyz.dylib
% install_name_tool -change 'libxyz.dylib' '/tmp/lib/libxyz.dylib' main
3.2 #executable_path
If you can recompile both the library and the main binary:
% cc -Wall -O3 -shared -o lib/libxyz.dylib xyz.c -Wl,-install_name,'#executable_path/lib/libxyz.dylib'
% cc -Wall -O3 -o main main.c -Llib -lxyz
If you can only recompile the main binary:
% install_name_tool -id '#executable_path/lib/libxyz.dylib' lib/libxyz.dylib
% cc -Wall -O3 -o main main.c -Llib -lxyz
If you cannot recompile either:
% install_name_tool -id '#executable_path/lib/libxyz.dylib' lib/libxyz.dylib
% install_name_tool -change 'libxyz.dylib' '#executable_path/lib/libxyz.dylib' main
3.3 #rpath
Rpath requires manual addition of runtime paths, which requires some planning. Suppose you have the follwing file hierarchy:
a
bin/
b
libx.dylib
lib/
liby.dylib
libz.dylib
a and b are binaries that both link against libx and liby, which in turn both link against libz. For the install name of libz, you can use neither #executable_path (because a and b are in different directories) nor #loader_path (because libx and liby are in different directories). But you can use either of them inside #rpath, and here is the decision you have to make:
You can either embed an rpath of #executable_path in a and #executable_path/.. in b. Then you can use #rpath to refer to the project root from all binaries. libz would have an install name of #rpath/lib/libz.dylib.
Or you can embed an rpath of #loader_path/lib in libx and #loader_path in liby. Then you can use #rpath to refer to the directory containing each binary. libz would have an install name of #rpath/libz.dylib.
I generally find the former to be easier to deal with, but the latter may be preferable if you have a large number of binaries scattered over many directories and only a few libraries.
To actually add an rpath to a binary, you can use:
cc -Wl,-rpath,... at compile time.
install_name_tool -add_rpath ... afterwards.
So if you can recompile both the library and the main binary:
% cc -Wall -O3 -shared -o lib/libxyz.dylib xyz.c -Wl,-install_name,'#rpath/lib/libxyz.dylib'
% cc -Wall -O3 -o main main.c -Llib -lxyz -Wl,-rpath,'#executable_path'
If you can only recompile the main binary:
% install_name_tool -id '#rpath/lib/libxyz.dylib' lib/libxyz.dylib
% cc -Wall -O3 -o main main.c -Llib -lxyz -Wl,-rpath,'#executable_path'
If you cannot recompile either:
% install_name_tool -id '#rpath/lib/libxyz.dylib' lib/libxyz.dylib
% install_name_tool -change 'libxyz.dylib' '#rpath/lib/libxyz.dylib' main
% install_name_tool -add_rpath '#executable_path' main
Note that if any of your binaries are signed, this will of course invalidate that signature. Use codesign -f ... to replace the existing signature(s).

Related

Missing libclang_rt.tsan-x86_64.a on clang-7.0

I am trying to hunt down some deadlock in multi-threaded code which uses a condition variable. Somebody advised using thread sanitizer. So I compiled LLVM from source and enabled thread sanitizer
LLVM built fine, but when I try to build my project I run into a lot of warnings of this kind:
: && /home/dzenan/LLVM-rel/bin/clang++ -fsanitize=thread -Wall -Wcast-align -Wdisabled-optimization -Wextra -Wformat=2 -Winvalid-pch -Wno-format-nonliteral -Wpointer-arith -Wshadow -Wunused -Wwrite-strings -funit-at-a-time -Wno-strict-overflow -Wno-deprecated -Wno-invalid-offsetof -Wno-undefined-var-template -Woverloaded-virtual -w -O2 -g -DNDEBUG -fsanitize=thread Modules/ThirdParty/VNL/src/vxl/v3p/netlib/tests/CMakeFiles/netlib_lsmrTest2.dir/lsmrTest2.cxx.o -o bin/netlib_lsmrTest2 -Wl,-rpath,/home/dzenan/ITK-git-clang/lib lib/libitkv3p_netlib-5.0.so.1 -lm && :
/usr/bin/ld: cannot find /home/dzenan/LLVM-rel/lib/clang/7.0.0/lib/linux/libclang_rt.tsan-x86_64.a: No such file or directory
/usr/bin/ld: cannot find /home/dzenan/LLVM-rel/lib/clang/7.0.0/lib/linux/libclang_rt.tsan_cxx-x86_64.a: No such file or directory
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
[1507/5739] Building C object Modules/ThirdParty/VNL/src/vxl/v3p/netlib/CMakeFiles/itknetlib.dir/triangle.c.o
FAILED: bin/netlib_lsqrTest1
What am I doing wrong and how to fix it?
I had this problem too. In my case, although these libraries were present in the system, they were not in a place where the linker could find them.
I solved that problem in a one-shot way by running this in the terminal I was using for compilation (replace the path with your local equivalent): export LD_LIBRARY_PATH=/lib64/clang/14.0.3/lib/linux/
It is only applied to the current terminal though. You may need to repeat that process each time, or use some persistent way of setting this for it to work everywhere.

Building ARM code on OS X

I am targeting the Cortex-A7 (ARMv7-A)
As a test:
bootstrap.s
.globl _start
_start:
mov sp,#0x00010000
bl main
hang: b hang
main.c
int main(void) { return 0; }
Trying:
$ as -arch armv7 -march=armv7-a -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=neon-vfpv4 bootstrap.s -o bootstrap.o
$ file bootstrap.o
bootstrap.o: Mach-O object arm
$ clang -c -arch armv7 -march=armv7-a -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=neon-vfpv4 main.c -o main.o
$ file main.o
notmain.o: Mach-O object arm
Confirms the compilation of Mach-O arm object files (also verified using hexdump, otool, gobjdump)
But now we try to link them together:
$ ld -e _start -arch armv7 bootstrap.o main.o -o foo
ld: warning: -ios_version_min not specified, assuming 6.0
ld: building for iOS, but linking in object file built for OSX, file 'bootstrap.o' for architecture armv7
And we have some issues. Not sure what's going on here. I haven't asked to link-in any iOS-related stuff. Using the -t linker flag confirms that no other objects are being linked in. Not sure why it thinks bootstrap.o is built for OS X when it clearly is a Mach-O arm file. Not sure if I'm passing the right flags to the assembler (pretty much all of them are undocumented?) or the linker
Note that this is for a bare-metal mini-project running on RPi2. I'm going to gobjcopy the linked executable object to a flat binary anyways. I'm just working with Mach-O since that's the only object type the system linker on OS X is capable of working with (and fat Mach-O). If I built a separate cross-compiler, I would be doing the exact same thing, instead I'd be linking ELF files before converting them to flat binary (I can output ELF32 files using clang/llvm anyways, I just cant link them). Seems silly to build a separate cross-compiler when clang/llvm is a perfectly suitable cross-compiler that's able to target my microarchitecture

Armadillo Wrapper Linker errors

When using some functions in the Armadillo Algebra package I get the following errors:
armadillo_bits/atlas_wrapper.hpp:188: undefined reference to `clapack_dgetrf'
I have linked like this:
arm-linux-gnueabihf-g++ -march=armv7-a -mthumb-interwork -mfloat-abi=hard
-mfpu=neon
-mtune=cortex-a9 --sysroot=/home/mg/yocto/build/tmp/sysroots/socfpga_cyclone5
-DHAVE_CONFIG_H -I. -I.. --sysroot=/home/mg/yocto/build/tmp/sysroots
/socfpga_cyclone5 -g -O2 -L/opt/altera-linux/linaro/gcc-linaro-arm-linux-gnueabihf-
4.7-2012.11-20121123_linux/arm-linux-gnueabihf/lib -I/opt/altera-linux/linaro
/gcc-linaro-arm-linux-gnueabihf-4.7-2012.11-20121123_linux/arm-linux-gnueabihf
/include -llapack -lf2c -lblas -lm --sysroot=/home/mg/yocto/build/tmp/sysroots
/socfpga_cyclone5 -MT AlgoLibTests.o -MD -MP -MF .deps/AlgoLibTests.Tpo -c -o
AlgoLibTests.o AlgoLibTests.cpp
I followed the instructions here and everything went fine:
Cross-Compiling Armadillo Linear Algebra Library
Any Ideas?
It also took me some days to be able to install armadillo for my Android development. So I want to shared with you the experience to solve your problem.
The error undefined reference to `clapack_dgetrf' is a linking error. This function should be contained in one of these libraries -llapack -lf2c -lblas. Of course it is clapack, so it should be in the lapack library. Use the command nm to check if the lapack library (liblapack.a or liblapack.so) contains this symbol. I am sure you will find out the solution then. Hope it helps.

Clang linker issues (from source, to gcc-snapshot)

I cannot seem to get this to work. I configured with the --with-gcc-toolchain= where after the equals I put the directory where gcc was (/usr/lib/gcc-snapshot/bin).
I also looked into the answers to " clang linker problem" but I do not see how I can get the accepted answer to find the correct location, and the symlink answer would have worked, except that all of the directories that it is searching exist (copying the lib folder from gcc-snapshot to one of the include locations does not seem to help).
As suggested in the other question, the output of clang++ test.cpp -v:
bob#bob:~/programming$ clang++ test.cpp -v
clang version 3.3 (trunk 171350)
Target: x86_64-unknown-linux-gnu
Thread model: posix
"/home/bob/programming/build/Release+Asserts/bin/clang" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name test.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version 2.22 -momit-leaf-frame-pointer -v -resource-dir /home/bob/programming/build/Release+Asserts/bin/../lib/clang/3.3 -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /usr/local/include -internal-isystem /home/bob/programming/build/Release+Asserts/bin/../lib/clang/3.3/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/bob/programming -ferror-limit 19 -fmessage-length 80 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops -o /tmp/test-PWiB4M.o -x c++ test.cpp
clang -cc1 version 3.3 based upon LLVM 3.3svn default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/home/bob/programming/build/Release+Asserts/bin/../lib/clang/3.3/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
test.cpp:1:10: fatal error: 'iostream' file not found
#include
^
1 error generated.
clang version 3.3 (trunk revision 171350)
EDIT: There are no .o files in the Release+Asserts folder for the build. Is this normal? If not, why is this the case, and how can I fix it (if I can point it as clang's stdlib, then that works as well).
Edit 2: It also fails to compile int main(){return 0;} as it can't find crtbegin.o. Full output is as follows:
/usr/bin/ld: cannot find crtbegin.o: No such file or directory
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find -lgcc_s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The results after -v are the same as the above, but with the ending error being different.
Config.log:
The full file can be found here, but the first (non-comment) line is: $ ../llvm/configure --with-gcc-toolchain=/usr/lib/gcc-snapshot/gcc
The issue that we've identified is that gcc was installed with --prefix=/usr/lib/gcc-snapshot configure argument. and llvm was configured with --with-gcc-toolchain=/usr/lib/gcc-snapshot/gcc argument. It should be the same as the gcc installation prefix, i.e. --with-gcc-toolchain=/usr/lib/gcc-snapshot.
The question's current first line says " I configured with the --with-gcc-toolchain= where after the equals I put the directory where gcc was (/usr/lib/gcc-snapshot/bin).", and the current last line says "first (non-comment) line is: $ ../llvm/configure --with-gcc-toolchain=/usr/lib/gcc-snapshot/gcc"
That's puzzling, you might have thought that you had put the flag --with-gcc-toolchain=/usr/lib/gcc-snapshot/bin but you had actually put --with-gcc-toolchain=/usr/lib/gcc-snapshot/gcc
Regardless, I think you should try the following.
remove or rename the build directory (the directory where you ran the configure command, i.e. the directory where you found the config.log file) I assume it's the /home/bob/programming/build directory.
now create /home/bob/programming/build directory again. it should be empty now.
cd /home/bob/programming/build
run the following configure command
../llvm/configure --with-gcc-toolchain=/usr/lib/gcc-snapshot
follow through with the rest of your build process.
The issue seems to be that you didn't specify the gcc-toolchain prefix correctly. It should be the same as the --prefix parameter you used while configuring the gcc.
Report back the results here.
Also see Clang 3.2 build broken after building gcc 4.7

beginner to use assimp in 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.

Resources