duplicate symbol _encode64_base

   今天遇到了这个问题,网上的修改编译tag,去除-all_load的方案没有用,但是别人转的国外牛人的方案倒是启发很大,转载如下:

I'm going to assume that these are two third party libraries that have only provided you with the .a files and not the source code. You can use libtool, lipo and ar on the terminal to extract and recombine the files.
假设有两个三方类库仅提供给你了.a文件,没有源码,你可以通过libtool, lipo和ar在terminal中解压合并他们。
To see what architectures are in the file:
查看文件都支持了什么架构
$ lipo -info libTapjoy.a
Architectures in the fat file: libTapjoy.a are: armv6 i386

Then to extract just armv6, for example:
然后只解压armv6,例如
$ lipo -extract_family armv6 -output libTapjoy-armv6.a libTapjoy.a
$ mkdir armv6
$ cd armv6
$ ar -x ../libTapjoy-armv6.a

You can then extract the same architecture from the other library into the same directory and then recombine them like so:
你可以从另一个类库中解压同样架构的部分,然后将两者合并在一起
$ libtool -static -o ../lib-armv6.a *.o

And then finally, after you've done this with each architecture, you can combine them again with lipo:
如上所示,你可以将所有架构都按照这个流程走一遍,然后合并
$ cd ..
$ lipo -create -output lib.a lib-armv6.a lib-i386.a

This should get rid of any duplicate symbols, but will also combine the two libraries into one. If you want to keep them separate, or just delete the duplicate from one library, you can modify the process accordingly.
这个过程不仅解决掉了duplicate symbols的问题,也将两个类库合并为一个。如果你想分别保存两个类库,你可以将duplicate的部分从任意一个类库中删除,你可以相应的修改这个过程。

       虽然这个方法并没有帮我解决问题:腾讯的TencentOpenAPI是一个framework,倒是可以解出*.o文件来,libzbar.a解出来也没有什么问题,只是两个*.o文件还是没办法修改。我这里说明一下:我在真机上调试是没有问题的,但是模拟器是有问题的,再去动*.o文件估计就到反汇编了,没那么高端。

       后来发现zbar是开源的,直接下载下来修改之后重新编译生成libzbar.a就可以再模拟器上跑了。


       装载这个的主要目的是保留上面的那些命令,对编译链接的掌握本来就是我们常说的基本功。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章