assimpExample runs in simulator but not on device

Hey guys,

I’m having an issue with 007, both the official bundle and the most recent GitHub, where the assimpExample in iPhoneAddonsExamples works in the simulator, but on the iPhone 4 and iPad (OS 4.3.5) I get a EXC_BAD_ACCESS:

aiVector3D.h on line 63 – aiVector3D () : x(0.0f), y(0.0f), z(0.0f) {}

Is anyone able to run the example on a device? Any known fixes?

Steve

I’ve found a solution for to compile the assimp library examples on iPhone / iPad devices:

Set the compiler to GCC 4.2 – by default in the newer versions of xCode, it’s LLVM GCC 4.2, which fail on the device at the aiVector3D() line above.

The downside is Apple is no longer supporting the GCC compiler, and is moving to LLVM. I tried re-compiling the assimp libraries from source without luck on the newer compiler. If there are any more future-proof solutions, let me know… in the meantime, it’s working!

![](http://forum.openframeworks.cc/uploads/default/1846/Screen shot 2011-09-15 at 2.35.46 PM.png)

Is anyone else having this issue?

I can’t run the assimp loader on an iOS5 device if I’m using the latest Xcode 4.2. Xcode 4.2 doesn’t have the GCC 4.2 compiler and neither LLVM GCC 4.2 or LLVM 3.0 work.

My running code gets the same error as Stephen - EXC_BAD_ACCESS in aiVector3D

Assimp needs to be compiled from scratch for LLVM, unfortunately thier CMake doesn’t support LLVM and aiDefines.h has the following:

  
#if defined(_MSC_VER)  
	// See [http://msdn.microsoft.com/en-us/library/b0084kay.](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.](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  

So I think you’d need to mess with a bit to get it compiled, but the iOS OF devs of the world would gift you 1000 internets if you get the library properly compiled with LLVM. I’m on old XCode until a project ends, so if it’s still not sorted by then I can do it, but it’ll be a few weeks.

The svn trunk of assimp adds an ARM architecture, but does not split it out to LLVM or to iOS for that matter.

  
#	elif defined(ANDROID)  
#		define ASSIMP_BUILD_ARM_32BIT_ARCHITECTURE  

A few questions if you don’t mind:

  1. So if I can compile a static library for assimp using LLVM and then replace assimp.a I should be on the right track?
    of_preRelease_v007_iphone/addons/ofxAssimpModelLoader/libs/assimp/lib/osx/assimp.a & iPhone/assimp.a

  2. I’ve been working with the assimp trunk, but is the OF source available that was used to build the OF version of the assimp library. I can’t find it on Github.

  3. Would I have better luck working with the latest Github source?

If you figure this out let me know… I’ve got an install of Xcode 4.1 just for a project using ASSIMP, but it worries me as newer versions of Xcode no longer support the GCC compiler.

I wasn’t able to compile ASSIMP for LLVM (Josh’s note above), and set it aside as I found a workaround with 4.1. I’d be happy to dive back in again if needed.

My understanding on 1. is yes, replace assimp.a in the two folders, and 2. – I downloaded from the SourceForge page: http://assimp.sourceforge.net/main-downloads.html

Hi Stephen,

I haven’t figured it out yet to work with OF, but a developer on the assimp team has updated the SVN to include a cmake script in port/iOS to build a LLVM GCC 4.2 version of the library.

When I bring the library into the OF assimp example I still get an EXC_BAD_ACCESS though. Maybe you can get farther than me, but I’m not even able to debug it in this state.

Thanks,
Ryan

anyone have any luck w this? I downgraded to xcode 4.1, but sadly can not roll back from ios 5 on my device!

Dropped the ball on responding here.

  1. So if I can compile a static library for assimp using LLVM and then replace assimp.a I should be on the right track?
    of_preRelease_v007_iphone/addons/ofxAssimpModelLoader/libs/assimp/lib/osx/assimp.a & iPhone/assimp.a

I think so, yes.

  1. I’ve been working with the assimp trunk, but is the OF source available that was used to build the OF version of the assimp library. I can’t find it on Github.

The version of Assimp was *probably* the latest release or maybe one back. I can’t imagine that it would be a big difference though, the main problem is getting is cross-compiled for ARM.

  1. Would I have better luck working with the latest Github source?

Of OF? It shouldn’t matter too much for this, though there have been some iOS fixes I don’t think any of them are related to Assimp.

There is something underway there to get Assimp iOS ready, http://assimp.svn.sourceforge.net/viewvc/assimp/trunk/port/iOS/ but I’m not sure how far along it is. This line:

"To build for iOS simply execute “./build_ios.sh” from this folder. Currently this script requires the latest SDK (5.0) from Apple in order to build properly. In the future I will add support for specifying the SDK version on the command line. "

means I can’t run it but it looks easy.

The library is easy to build and compiles just fine. When I bring it back into OF I don’t have any luck getting past the EXC_BAD_ACCESS error in aiVector.

Is there anyone who has upgraded to Xcode 4.2 that is willing to take a look at this?

Thanks!

I can also report that I can’t get this to work. I’ve recompiled assimp.a from their SVN and copied it across. I’ve recompiled the project with LLVM GCC 4.2, but I still get the crash on a class constructor:

#0 0x001974ac in aiVector3D::aiVector3D() ()
#1 0x0000fcec in ofxAssimpModelLoader::ofxAssimpModelLoader() at /Users/ajs/dev/of_preRelease_v007_iphone/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp:128
#2 0x00003c64 in testApp::testApp() ()
#3 0x000024a8 in main at /Users/ajs/dev/of_preRelease_v007_iphone/apps/iPhoneAddonsExamples/assimpExampleTest/src/main.mm:14

This is related to the default construction of variables:

aiVector3D scene_min, scene_max, scene_center

in ofxAssimpModelLoader.h but it you just cut those out and workaround for testing, you hit other strange errors to do with static initialisation of strings inside assimp.

Also reference is made to running on iOS5 devices. I can’t run it on my iphone with 4.3.2 either.

ajs

hi, im also looking into this now.
ive tried recompiling the library from their SVN but getting some errors.

@ajs, are you using the build_ios.sh script to build the library?

im getting this error,
error: -mmacosx-version-min not allowed with -miphoneos-version-min

not sure how to get around this…

L.

ok, this was a bug with an older version of cmake that i had installed.
upgrading the the latest (2.8.7) had fixed this error.
bring on the next hurdle!

ive done a little digging around the internets and it can potentially be a LLVM bug.
found a few bug reports that describe similar behaviour.

i also got the latest trunk of Assimp compiling with GCC 4.2 - LLVM 3.0 but that didn’t resolve the issue.

in either case, until Assimp or LLVM resolve this issue ive downgraded to XCode 4.1 using GCC 4.2
everything works and i can run the example on my iOS5 device.

L.

Thanks for taking a look.

For anyone else reading this, it is still possible to download XCode 4.1. I found it by searching on the developer forum to get the link.

ive recently upgraded to Lion and running the latest Xcode 4.3.1
using the Apple LLVM compiler 3.1 this is no longer an issue.
it must have been an issue with the LLVM 3.0 compiler all along…

not sure what can be done for the people still using this compiler.
probably the only thing to do is to downgrade to XCode 4.1 and use the GCC 4.2 compiler or upgrade to latest Xcode 4.3.1 on Lion and use LLVM 3.1 compiler.

I can confirm that the latest XCode fixes the issue for me also.

for people interested in a fix for LLVM 3.0 or if you are still having this issue.
see: https://github.com/openframeworks/openFrameworks/issues/723#issuecomment-5740094