duplicate symbol _SBJSONErrorDomain in:

本文介绍了一种解决iOS项目中使用多个静态库导致符号重复的方法。通过在编译阶段利用预处理器自动重命名冲突符号,可以有效避免ld:duplicate symbol错误。文中还提到了当无法访问外部库源码时的替代解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

If your iOS project use external static library, sooner or later you will encounter errors like this:

ld: duplicate symbol _SBJSONErrorDomain in ...

This happens when you use library A and library B, each use the same third party library such as SBJson.

One usual way to fix this is rename the conflicting symbol. e.g. rename one of the SBJson to some like LibASBJson. This however require manual work and is error prone.

Today I learn a simpler alternative: Use the preprocessor to rename the symbols automatically during the build phase.

For each of the duplicated symbols, add "-DSBJSONErrorDomain=LibASBJSONErrorDomain" flags to the ‘Other C Flags’ build setting for the library project. You'll found no more duplicate symbol after this setting!

Note: If both library are external and you have no access, you probably need to revert to nasty hacks such as removing classes from static libraries or objcopy.

转载于:https://www.cnblogs.com/crazy-programmer/archive/2013/02/25/2932081.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值