静态库具有相同的函数名称,导致重复的符号错误 [英] Static libraries have same function names causing duplicate symbol error

查看:888
本文介绍了静态库具有相同的函数名称,导致重复的符号错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iPad应用中使用了2个第三方库。我不知道这些库的源代码。
这些库在两者中都具有相同名称的函数。因为功能名称中的冲突,我得到Apple Mach-O(id)错误。我无法更改其中的函数名称,因为源代码未知。在构建应用程序时,错误正在发生。

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.

错误说明:


ld:/ Users / Desktop / untitled中的重复符号_T_strcpy
文件夹/ Universal / lib / simulator / myLib.a(mem.o)和
/ 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返回1退出状态命令
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-g++-4.2
因退出代码1而失败

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??

推荐答案

你几乎搞砸了。原始库的创建者失败了库开发的最基本规则之一:使用库特定前缀预先添加所有导出的符号,以避免命名空间冲突。

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.

你唯一的出路是用一个带有命名空间前缀名称的包装器来包装每个库中的每个函数,将库静态链接到包装器和 strip 所有未导出的符号。然后使用包装器库和符号名称。

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?

这篇关于静态库具有相同的函数名称,导致重复的符号错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆