Getting a static library to work on the iPhone in SDK 3

We are currently working on a lightweight game library for the iPhone. The library is static and is thus linked to the game at compile-time. In the iPhone simulator, it was working perfectly fine.

Then I wanted to do start the demo application on the actual device. For whatever reason, the classes of the library were not recognized on the device at runtime – even though the build log did not note any problems, and the library should have been linked to game. I could not think of anything that would lead to this behavior!

Fortunately, big brother Google was there for the rescue. There seems to be bug in the linker of iPhone SDK 3.0. The fix is easy (if you know it):

In addition to the linker flag “-ObjC” you have to add the flag “-all_load”. After that, everything works just like it should.

I suspect that Apple fixes this in the next SDK version, but until then, I can live with that.

Discussion

Holger Weissböck, 2009/08/03 06:45

Awesome find. Thanks.

 
blog/getting_the_static_library_to_work_on_the_iphone_in_sdk_3.txt · Last modified: 2009/10/19 05:00 (external edit) · [Old revisions]
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki