How to build ASSIMP Library for iOS (Device and Simulator) with boost-library?
I want to use the ASSIMP library http://assimp.sourceforge.net in an iOS project. Unfortunately, I’m not very experienced with makefiles and that stuff, so I need some help.
I’ve downloaded the sources and first I tried to build with make (in the code-subfolder)
In the makefile I’ve added
INCLUDEFLAGS = -I/Lib because my boost header-files are in /Lib/boost
make static succeeds with some warnings. A static library (.a) is generated.
Then I tried to add the .a-file to my xcode-project and specified the assimp-header folder as additional include directory (Other Search Paths). Linking failed with the message that the library has not the right architecture (i386 required for the simulator)
file libassimp.a outputs: “libassimp.a: current ar archive random library”
How can I build the library for the i386 architcture and for arm6 or arm7, whatever I need on an iOS device?
Is it ok to use the boost-headers only or is it better/necessary to build boost as a library? Currently I’m using boost headers only, which should be fine since boost is a header only library?!
There is also a cmake – makefile (CMakeLists.txt). cmake is the recommended way of building the library but I don’t have any experience with cmake.
Or another thought: Is it possible to build a library via xcode?
The final result should be a library for i386, arm6 and arm7 architecture.
What shall I do? And how?
I’ve just discovered that there are the following preprocessor checks in the file
#if defined(_MSC_VER) // See http://msdn.microsoft.com/en-us/library/b0084kay. # if defined(_M_IX86) # define ASSIMP_BUILD_X86_32BIT_ARCHITECTURE # elif defined(_M_X64) # define ASSIMP_BUILD_X86_64BIT_ARCHITECTURE # elif defined(_M_IA64) # define ASSIMP_BUILD_IA_64BIT_ARCHITECTURE # else # error unknown architecture # endif #elif defined(__GNUC__) // See http://gcc.gnu.org/onlinedocs/cpp/Predefined-Macros.html. # if defined(__x86_32__) || defined(__i386__) # define ASSIMP_BUILD_X86_32BIT_ARCHITECTURE # elif defined(__x86_64__) # define ASSIMP_BUILD_X86_64BIT_ARCHITECTURE # elif defined(__ppc__) # define ASSIMP_BUILD_PPC_32BIT_ARCHITECTURE # else # error unknown architecture # endif #else # error unknown compiler #endif
Does this mean, it is not possible to compile the ASSIMP library for ARM architecture?
- How can I get Xcode to link and debug an app with Boost Filesystem?
- cpprestsdk: Undefined symbols for architecture x86_64
- 'openssl/conf.h' file not found error on MacOS Sierra
- Boost Xcode C++ command line Undefined symbols for architecture x86_64
- Linker errors with Boost on Mac (OSX 10.10.02 | Xcode 6.1.1)
- Boost's thread group on Xcode
4 Solutions Collect From Internet About “How to build ASSIMP Library for iOS (Device and Simulator) with boost-library?”
I personally don’t do any iOS development, but I know that others have successfully compiled Assimp for their iDevices using Xcode. An Xcode 3 project should be included with the distribution, although I don’t know if you can use it without further modification.
The architecture preprocessor defines are currently only used for logging output (in
code/Importer.cpp), and support for ARM has been added to trunk in the meantime (r919, to be exact).
I also had a few issues getting assimp to work on iOS devices.
Here’s what I did in case anyone is also having similar issues – similar to Artur Sampaio’s example above, but with a few differences:
get the latest assimp from https://github.com/assimp/assimp, i.e., git clone git://github.com/assimp/assimp.git
cd into the assimp directory and open up CMakeLists.txt. For some reason, the make file couldn’t find my glut and gl libs, so I commented out the lines in CMakeLists.txt that referred to making the samples, i.e., the “IF ( BUILD_ASSIMP_SAMPLES)” block of code. There’s probably a simple way to point to these, but since I didn’t need the samples I just did commented those lines out.
cd to port/iOS/ and then sudo ./build_ios.sh (it takes a few minutes to compile all 3 versions of the lib).
now if you cd to assimp/lib/ios and lipo -info libassimp.a you will see that the library is a fat file with i386, arm6 and arm7 architectures (and will work on both the simulator and the arm6 or arm7 device).
to get it to work in XCode 4.3.2, drag&drop the libassimp.a file into my project (from the finder). You don’t have to actually copy it over to your project directory, it doesn’t hurt if you do though.
for some reason, a build will still fail unless you explicitly link to the libz dynamic library. Click the main project from the XCode file list, select TARGETS, then click on the Build Settings tab, scroll down to the Linking section, and then add “/usr/lib/libz.dylib” under “Other Linker Flags”.
the current version of assimp on github seems to have restructured the code somewhat, and while all of the examples I tested from the assimp website work, they all require different, or at least renamed, header files:
Here I’ve commented out the previous names of the headers and below are the new names:
//#include <assimp.hpp> // C++ importer interface //#include <aiScene.h> // Output data structure //#include <aiPostProcess.h> // Post processing flags #include "Importer.hpp" #include "scene.h" #include "postprocess.h"
After this point I was able to use assimp on my iPad.
Also, you probably want to make sure that you have uninstalled other versions of assimp before doing this (eg from macports or brew).
What I did was:
download version 1090 of the Assimp repo: http://assimp.svn.sourceforge.net/viewvc/assimp/trunk/?pathrev=1090
(replace ~/Downloads/trunk with the path to the unzipped folder)
check libs at ~/Downloads/trunk/libs/ios/
hope that works
- NSCalendar to Display Weekday
- How to make “shaking” animation
- Making Swift generics play with overloaded functions
- UIScrollView scroll not working after pushed with a navigation controller
- Auto Boxing of primitives
- Hide UITableView on touches outside the tableview
- set UIImageView.image in prepareForSegue
- Comparing two NSDates and ignoring the time component
- filled antialiased poly cocos2d
- What format does NSKeyedArchiver save?
- NSCollectionView with sections – like in iPhoto
- How to access clipboard data programmatically ?
- Mac OSX – Xcode Installation Directory
- How can I subclass a UITableView?
- Convert between Decimal, Binary and Hexadecimal in Swift