Static libraries have same function names causing duplicate symbol error

*爱你&永不变心* 提交于 2019-12-07 13:24:05

问题


I am using 2 third party libraries in my iPad app. The source code for these libraries are not known to me. These libraries have the functions with same name in both. So I am are getting "Apple Mach - O (id) error" because of the collision in function names. I cant change the function names within them, as source code is not known. On building the app the error are occurring.

The error states that:

ld: duplicate symbol _T_strcpy in /Users/Desktop/untitled folder/Universal/lib/simulator/myLib.a(mem.o) and /Users/Library/Developer/Xcode/DerivedData/iOS-aqpprpcivvjjadbsutqqmtjsoczk/Build/Intermediates/ios.build/Debug-iphonesimulator/myApp iPad.build/Objects-normal/i386/pdcrypte2.o for architecture i386 collect2: ld returned 1 exit status Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-g++-4.2 failed with exit code 1

Can anybody share some suggestions??


回答1:


You're pretty much screwed. The creators of the original libraries failed one of the most basic rules of library development: Prepend all your exported symbols with a library specific prefix, to avoid namespace collisions.

Your only way out is to wrap each and every function from each library with a wrapper that has a namespace prefixed name, statically link the library to the wrapper and strip all not exported symbols. Then use the wrapper libraries and symbol names.

Actually if the libraries are static you can fix this issue: How to deal with symbol collisions between statically linked libraries?



来源:https://stackoverflow.com/questions/6937501/static-libraries-have-same-function-names-causing-duplicate-symbol-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!