Conflict between my own static C library and libiPhone.a provided by Unity3D on iOS

Hello,

I’m using a freshly built static library of libjpeg turbo and trying to get this deployed to iOS. Several duplicate symbol errors seem to suggest that the Unity provided libiPhone.a already contains an (older) version of this library. I’ve looked into the static lib and found almost all relevant .o files for it. Unfortunately I need my own build of this lib for my project.

What would be the best way to solve this? Would I have to merge both static libraries with lipo/ar in order to “inject” my build? Any ideas?

Thanks
Ben

1 Like

Just found a post mentioning a similar problem.

http://forum.unity3d.com/threads/129530-duplicate-symbol-in-static-libraries-%28damn-I-hate-that…%29

Seems like it would be a good idea to have those 3rd party static libs seperately distributed with Unity and not compiled into one monolithic lib file.

The best explanation so far on how to solve this has been posted here:

http://stackoverflow.com/questions/6940384/how-to-deal-with-symbol-collisions-between-statically-linked-libraries/6940389#6940389

Ben

Ok, the solution above is not applicable here, because there is no objcopy on OSX and we wouldn’t be able to alter our symbols in the way described.

So it came down to change all exported symbols in the libjpeg I’ve build myself. Fortunately there is a define that comes in handy. In jconfig.h.in enable the define

this option normally helps to avoid linker problems with symbol names too long. But in my case it conveniently prevents all conflicts with the libjpeg version added to the Unity3D static lib. Just change your client code in order to use the new function names (the list you’ll find in jpeglib.h when searching for the NEED_SHORT_EXTERNAL_NAMES).

Cheers,
Ben

1 Like