Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid duplicate symbols between 3rd party frameworks

I have a bit of a dilemma. I have added 2 frameworks into my project and so it just happens that both use JSONKit. So when I compile my project I get duplicate symbols between these 2 frameworks.

I had to add -ObjC -all_load into my build settings otherwise I would get runtime errors (crashes) due to some categories not being compiled.

Any ideas?

like image 309
MrShoot Avatar asked Aug 27 '12 20:08

MrShoot


1 Answers

When you link static-library, linker will embed all symbols into your final binary. (that's why it is named static.) Actually there's no good way to strip off specific symbols, because there's no difference between source symbols and newly embedded symbols. Even you can strip off duplicated symbols, nobody can sure that duplicated symbols are same version. If one library used modified version of JSONKit library, it will be broken when you replace it with other version.

The only way is getting .a file without the duplicated symbols or get the source and compiling them yourself. If the lib makers are not idiots, they should offer some version of library without embedded symbols. If there's no such thing, I strongly recommend not to use that lib. Because it has no concern of symbol conflict which means made by real newbie which means it's full of problems.

like image 60
eonil Avatar answered Oct 20 '22 01:10

eonil