开发者

Static libraries have same function names causing duplicate symbol error

开发者 https://www.devze.com 2023-03-25 22:58 出处:网络
I am using 2 third party libraries in my iPad app. The source code for these libraries are not known to me.

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开发者_如何学Python.2 failed with exit code 1

Can anybody share some suggestions??


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号