Xcode编译报错duplicate symbol _base64Decode in:

来源:互联网 发布:农村网络信息 编辑:程序博客网 时间:2024/06/05 18:23

如题,我的项目中用到了zBarSDK和微信SDK,然后编译时报错:

duplicate symbol _base64Decode in:
    /Users/Evan/Documents/work-fight/JdysrFight/fightGame/frameworks/runtime-src/proj.ios_mac/ios/wxSDK/libWeChatSDK.a(base64.o)
    /Users/Evan/Library/Developer/Xcode/DerivedData/fightGame-guhgqdxpcitnbxafrzzllmvwrjto/Build/Products/Debug-iphoneos/libcocos2d iOS.a(base64.o)
duplicate symbol _main in:
    /Users/Evan/Library/Developer/Xcode/DerivedData/fightGame-guhgqdxpcitnbxafrzzllmvwrjto/Build/Intermediates/fightGame.build/Debug-iphoneos/fightGame-mobile.build/Objects-normal/arm64/main.o
    /Users/Evan/Library/Developer/Xcode/DerivedData/fightGame-guhgqdxpcitnbxafrzzllmvwrjto/Build/Products/Debug-iphoneos/libcocos2d iOS.a(flatc.o)
ld: 2 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

原因:

意思就是在这两个库中都定义了_base64_encode,编译器认为你重复定义了。至于为什么编译器认为重复定义,个人认为编译器编译全局变量时会根据名字进行编译,会把相同名称的全局变量编译为相同变量,也就是多个编译成一个,而编译器认为这样可能会引起错误,就提醒用户这里有错。

解决方法:

删掉 TARGETS->Build Settings->other linker flag-> -all_load 

0 0