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就可以再模擬器上跑了。


       裝載這個的主要目的是保留上面的那些命令,對編譯鏈接的掌握本來就是我們常說的基本功。

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