duplicate symbols for architecture x86_64

出现这个问题主要有一下几种原因:

1、项目使用CocoaPods管理后,没有删除之前手动引入的文件。

引入CocoaPods还需要在项目target中的build setting中的other flags加入$(inherited)。在framework search path和Library search path中也加入$(inherited),删除其他的条目。

2、在文件中引入了.m文件,本来应该是需要引入.h文件。

3、Remove -ObjC from Other Linker Flags or Please check you imported any .m file instead of .h by mistake.

4、今天在项目里拖进了一个第三方SDK的源码,项目编译时fail,错误信息是duplicate symbols for architecture arm64。百度半天无果,只能询问SDK开发的小伙伴,告诉我需要修改Build Settings里的No Common Blocks为NO。No Common Blocks的Quick Help信息如下:

GCC_NO_COMMON_BLOCKS 
In C, allocate even uninitialized global variables in the data section of the object file, rather than generating them as common blocks. This has the effect that if the same variable is declared (without extern ) in two different compilations, you will get an error when you link them. 
[GCC_NO_COMMON_BLOCKS, -fno-common]

原来是在这个SDK里有的头文件声明了公共变量,然后在另外几个文件里import了这个头文件,No Common Blocks默认为YES,编译器就报错了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值