日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

探讨NDK编译错误ld.exe: Dwarf Error: mangled line number section.

發布時間:2023/11/29 编程问答 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 探讨NDK编译错误ld.exe: Dwarf Error: mangled line number section. 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

如題所示的NDK編譯錯誤是什么原因導致的?

我的困惑


今天在把WIN32下的一個工程移植到ANDROID時遇到上述錯誤,感到非常困惑。錯誤如下:


D:/ndkr8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/../lib/gcc/
arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld.exe: Warnin
g: ./obj/local/armeabi/webp.a(alpha.o):?Unknown EABI object attribute 44
D:/ndkr8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/../lib/gcc/
arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld.exe: Warnin

..............................................................................(others omitted)

collect2:?ld returned 1 exit status
make: *** [obj/local/armeabi/libgame_shared.so] Error 1
make: Leaving directory `/cygdrive/e/download2010/cocos2d-x/cocos2d-2.1rc0-x-2.1
.2/LittleWordNinjaAnd/proj.android'


也就是說,我的錯誤與http://www.eoeandroid.com/thread-263553-1-1.html處這位難友相同。他提交的錯誤信息是:


E:/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld.exe:?Dwarf Error: mangled line number section.
./obj/local/armeabi/webp.a(frame.o): In function `StoreSideInfo':
frame.c:(.text.StoreSideInfo+0xb4): undefined reference to `__gnu_thumb1_case_si'
collect2: ld returned 1 exit status

/cygdrive/e/android-ndk-r8/build/core/build-binary.mk:369: recipe for target `obj/local/armeabi/libgame.so' failed
make: *** [obj/local/armeabi/libgame.so] Error 1
make: 離開目錄“/cygdrive/e/cocos2dx/cocos2d-2.1rc0-x-2.1.2/cocosdemo/proj.android”


出錯信息如上,是因為我的cygwin少下了什么組件嗎?



目前找到的中文參考有:

1.http://blog.csdn.net/huangtaiquan/article/details/7090901

文章如下:


今天出現了編譯的時候,把項目src中的文件都編譯成.o文件后,把所有的.o文件整合成為可執行文件的時候,出現了ld: Dwarf Error: mangled line number section. 錯誤提示。

后來發現原因是由于調用其他的lib,但是某個lib是使用gcc-4.6版本編譯的。而當前使用gcc-4.1版本。故使用gcc-4.1重新生成新的lib后,就不會出現問題了。


2.http://blog.csdn.net/lwuit/article/details/7906104

她提示的信息有:


在編譯cocos2d-x的helloworld 或者 tests的時候。

官網上使用ndk4、ndk5,這里是使用 ndkr7b、ndkr8或ndkr8b 。操作會簡單很多,但是出了些小問題也是很坑人的。

下面出現如下編譯錯誤

[javascript]?view plaincopy

  • Prebuilt???????:?libgnustl_static.a?<=?<NDK>/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/??

  • SharedLibrary??:?libcocos2d.so??

  • g:/handgame/tools/android-ndk-r8b/toolchains/arm-linux-androideabi-4.6/prebuilt/?????????????????????????????

  • [javascript]?view plaincopy

  • windows/bin/../lib/gcc/arm-linux-androideabi/4.6.x-google/../../../../arm-linux-?????????????????????????????

  • [javascript]?view plaincopy

  • androideabi/bin/ld.exe:?cannot?find?./obj/local/armeabi/libgnustl_static.a:???

  • [javascript]?view plaincopy

  • Permission?denied??

  • collect2:?ld?returned?1?exit?status??

  • /cygdrive/g/HandGame/tools/android-ndk-r8b/build/core/build-binary.mk:378:???

  • [javascript]?view plaincopy

  • recipe?for?target?`obj/local/armeabi/libcocos2d.so'?failed??

  • ?

    在helloworld中找到Application.mk文件添加如下內容:STLPORT_FORCE_REBUILD := true



    3.http://www.eifr.com/article.php?id=603

    有作用的提示有:


    Linux下創建線程時,編譯時會出現下面的錯誤,
    [root@linuxserver 807]# gcc -o 22 22.c
    /tmp/cc21HcoW.o(.text+0x4c): In function `main':
    : undefined reference to `pthread_create'
    collect2: ld returned 1 exit status...........................
    此時,只需改變編譯方式
    將gcc -o 22 22.c 改變為 gcc -O2 -Wall -o 22 22.c -lpthread

    最關鍵的是-lpthread

    根據錯誤
    /tmp/cc21HcoW.o(.text+0x4c): In function `main':
    : undefined reference to `pthread_create'
    collect2: ld returned 1 exit status
    可以看出是在ld的時候系統無法找到pthread_create函數。也就是說編譯器在link得時候找不到其中的一個使用庫的函數。
    如果差pthread_create的話可以發現其在pthread.so中,所以需要增加 -lpthread編譯參數,告訴linker在link的時候使用pthread模塊





    英文參考


    又找到一篇英文參考如下:
    URL: http://stackoverflow.com/questions/11715999/ndk-build-causes-error


    3?down votefavorite

    I had been trying to solve this issue for quiet a long time,I am using a library called FreeImage and when tries to do the NDK build the code results in following error My source can be downloaded from

    copy.html">http://www.4shared.com/zip/1C3vpLI7/android-p_w_picpathfilter-ndk_copy.html Thanking you in advance for your valuable efforts-

    tribute.cpp+0x8):?undefined?reference?to?`std::ios_base::Init::Init()' ImfChromaticitiesAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfChromaticitiesAttribute.cpp+0x24):?undefined?reference?to?`std::ios_base::Init::~Init()' /home/flock/ANDROID/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld:?Dwarf?Error:?mangled?line?number?section. ./obj/local/armeabi/libfreep_w_picpath.a(ImfCompressionAttribute.o):?In?function?`_GLOBAL__sub_I_ImfCompressionAttribute.cpp':ImfCompressionAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfCompressionAttribute.cpp+0x8):?undefined?reference?to?`std::ios_base::Init::Init()' ImfCompressionAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfCompressionAttribute.cpp+0x24):?undefined?reference?to?`std::ios_base::Init::~Init()' ./obj/local/armeabi/libfreep_w_picpath.a(ImfCompressor.o):?In?function?`Imf::newCompressor(Imf::Compression,?unsigned?int,?Imf::Header?const&)':ImfCompressor.cpp:(.text._ZN3Imf13newCompressorENS_11CompressionEjRKNS_6HeaderE+0x10):?undefined?reference?to?`__gnu_thumb1_case_uqi' ImfCompressor.cpp:(.text._ZN3Imf13newCompressorENS_11CompressionEjRKNS_6HeaderE+0xb8):?undefined?reference?to?`__cxa_end_cleanup' ./obj/local/armeabi/libfreep_w_picpath.a(ImfCompressor.o):(.ARM.extab.text._ZN3Imf13newCompressorENS_11CompressionEjRKNS_6HeaderE+0x0):?undefined?reference?to?`__gxx_personality_v0'./obj/local/armeabi/libfreep_w_picpath.a(ImfCompressor.o):?In?function?`Imf::newTileCompressor(Imf::Compression,?unsigned?int,?unsigned?int,?Imf::Header?const&)': ImfCompressor.cpp:(.text._ZN3Imf17newTileCompressorENS_11CompressionEjjRKNS_6HeaderE+0x12):?undefined?reference?to?`__gnu_thumb1_case_uqi' ImfCompressor.cpp:(.text._ZN3Imf17newTileCompressorENS_11CompressionEjjRKNS_6HeaderE+0x64):?undefined?reference?to?`__cxa_allocate_exception'ImfCompressor.cpp:(.text._ZN3Imf17newTileCompressorENS_11CompressionEjjRKNS_6HeaderE+0x8a):?undefined?reference?to?`__cxa_throw' ImfCompressor.cpp:(.text._ZN3Imf17newTileCompressorENS_11CompressionEjjRKNS_6HeaderE+0xe4):?undefined?reference?to?`__cxa_end_cleanup' ./obj/local/armeabi/libfreep_w_picpath.a(ImfCompressor.o):(.ARM.extab.text._ZN3Imf17newTileCompressorENS_11CompressionEjjRKNS_6HeaderE+0x0):?undefined?reference?to?`__gxx_personality_v0'./obj/local/armeabi/libfreep_w_picpath.a(ImfCompressor.o):?In?function?`_GLOBAL__sub_I_ImfCompressor.cpp': ImfCompressor.cpp:(.text.startup._GLOBAL__sub_I_ImfCompressor.cpp+0x8):?undefined?reference?to?`std::ios_base::Init::Init()' ImfCompressor.cpp:(.text.startup._GLOBAL__sub_I_ImfCompressor.cpp+0x24):?undefined?reference?to?`std::ios_base::Init::~Init()'./obj/local/armeabi/libfreep_w_picpath.a(ImfCompressor.o):(.data.rel.ro+0x0):?undefined?reference?to?`vtable?for?__cxxabiv1::__class_type_info' /home/flock/ANDROID/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld:?Dwarf?Error:?mangled?line?number?section. ./obj/local/armeabi/libfreep_w_picpath.a(ImfConvert.o):?In?function?`_GLOBAL__sub_I_ImfConvert.cpp': ImfConvert.cpp:(.text.startup._GLOBAL__sub_I_ImfConvert.cpp+0x8):?undefined?reference?to?`std::ios_base::Init::Init()'ImfConvert.cpp:(.text.startup._GLOBAL__sub_I_ImfConvert.cpp+0x24):?undefined?reference?to?`std::ios_base::Init::~Init()' /home/flock/ANDROID/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld:?Dwarf?Error:?mangled?line?number?section. ./obj/local/armeabi/libfreep_w_picpath.a(ImfDoubleAttribute.o):?In?function?`_GLOBAL__sub_I_ImfDoubleAttribute.cpp': ImfDoubleAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfDoubleAttribute.cpp+0x8):?undefined?reference?to?`std::ios_base::Init::Init()'ImfDoubleAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfDoubleAttribute.cpp+0x24):?undefined?reference?to?`std::ios_base::Init::~Init()' /home/flock/ANDROID/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld:?Dwarf?Error:?mangled?line?number?section. ./obj/local/armeabi/libfreep_w_picpath.a(ImfEnvmapAttribute.o):?In?function?`_GLOBAL__sub_I_ImfEnvmapAttribute.cpp': ImfEnvmapAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfEnvmapAttribute.cpp+0x8):?undefined?reference?to?`std::ios_base::Init::Init()'ImfEnvmapAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfEnvmapAttribute.cpp+0x24):?undefined?reference?to?`std::ios_base::Init::~Init()'


    My Android.mk

    LOCAL_PATH?:=?$(call?my-dir)include?$(CLEAR_VARS)LOCAL_MODULE:=?freep_w_picpath LOCAL_SRC_FILES?:=libfreep_w_picpath.a include?$(PREBUILT_STATIC_LIBRARY)include?$(CLEAR_VARS)LOCAL_MODULE:=?p_w_picpathprocessing LOCAL_SRC_FILES:=?p_w_picpathprocessing.c LOCAL_STATIC_LIBRARIES?=?freep_w_picpath LOCAL_EXPORT_C_INCLUDES?:=?freep_w_picpath.h LOCAL_LDLIBS:=?-lm?-llog?-ljnigraphics? include?$(BUILD_SHARED_LIBRARY)

    My application.mk

    APP_OPTIM := release APP_PLATFORM. := android-8APP_STL := gnustl_static APP_CPPFLAGS += -frtti APP_CPPFLAGS += -fexceptions APP_CPPFLAGS += -DANDROID APP_ABI:= armeabi

    接下來是可能的一些師傅們的回答(跟帖):

    What do your Android.mk and Application.mk files look like?–?Michael?Jul 30 '12 at 5:56



    @Michael....Please see the edit?–?Sreekanth Karumanaghat?Jul 30 '12 at 6:03


    Looks like libfreep_w_picpath.a had been compiled incorrectly. Try to compile it exactly with same Android NDK you are compiling. Or better - dontuse static library. include the Android.ml makefile of FreeImage, and compile together with your code - it will guarantee that you won't have this kind of problem.?–?Mārti愁 Mo攁椀欀漀?Jul 30 '12 at 6:12


    What ABI are you building for? I see undefined references that indicate that some of the code was built for ARM, but you seem to be using an x86 toolchain.?–?Michael?Jul 30 '12 at 6:17


    @Martins Mozeiko...Hi I had been using a downloaded version of libfreep_w_picpath.a...How can I make my code to work??–?Sreekanth KarumanaghatJul 30 '12 at 6:31




    關閉cygwin,再次打開重新編譯,得到如下錯誤:



    真是莫名其妙???!!!

    ......

    After a long time of trying trying... I used the following solution:

    最后,我基本同意1.http://blog.csdn.net/huangtaiquan/article/details/7090901朋友提到的看法。現在,我重新使用了2.1.1,再重新走一遍上面的過程。OK!!!!!!!!

    另外,還得到如下一些教訓與您一起分享:

    第一,GCC編譯器比較于VC++更為嚴格,也就是說,你在WIN32下通過,在NDK下很可能存在問題。不過,問題不太大,你根據提示,作逐一修改即可。例如:

    我的程序在WIN32下調試時,許多的.h或者.cpp文件編碼使用的是UNICODE或者ANSI,而這很可能在NDK編譯下存在問題。一般地,你只需要把它們的編碼修改為UTF-8即可。
    我使用的工具是,EditPlus,感覺這個工具還是相當方便的。在許多情況下開啟許多文字型文件時你不需要啟動大型的工具,例如VS,即可達到修改的目的。

    第二,在WIN32編程時在resource文件夾下命名各種資源,主要是png文件,建議統一使用小寫。而且,在CPP文件中引用時也要保持一致的大小寫。否則,當你最后使用ECLIPSE下構建工程時可能會出現一連串的錯誤提示,例如assets下的某個png文件沒有找到之類的。
    當然,我是在我的WIN7+ECLIPSE+VS2010+COCOS2D-X 2.1.1平臺上得到如上結論的。對于你們則應當視自己的環境而定。

    總之,上面錯誤我還是沒有徹底解決,只是放棄了,而且選擇了2.1.1版本的COCOS2D-X罷了。

    補充:我目前之所以想選擇最新的2.1.2是因為其中有一個我需要的CCEDITBOX,在WIN32下測試CCEDITBOX是沒有問題的。但是,以前的版本下,如果不是使用例如
    網絡上其他的自己開發方式,是無法使用的。這一點,你在網絡的其他文章中也會得到這個結論。我是在2.1.2下調試通過CCEDITBOX,然后再挪動到2.1.1下的(就是說在
    這個版本下通過不了不要緊--只是CCEDITBOX這一小塊)。然后,拿到NDK下編譯就行。



    2013.5.19新參考內容添加如下:


    1.http://cocos2d.cocoachina.com/bbs/forum.php?mod=viewthread&tid=10750處提到:

    “這個問題我也遇到,我的解決理法是更新ndk到版本 android-ndk-r8e”

    2.http://www.eoeandroid.com/thread-263553-1-1.html處提到:

    “臥了個大槽,把NDK升級到最新版編譯通過了。”


    喜獲成功

    記得前幾天看到COCOS2D-X官方網站還提到說是COCOS2D-X 2.1.3版本在目前典型的NDK下編譯成功的,于是不死心,畢竟最新版本中提供了許多更好使用的功能,而且也消除了以前的不少BUG。于是,使用上面提到的方法,下載了NDKR8E,其他的沒有變(只是有關路徑設置位置由原來的NDK版本更改到現在版本),重新在CYGWIND下編譯項目,終于成功了!!!
    提示:我的GCC還是以前的版本1.4.4.


    無標題.jpg


    轉載于:https://blog.51cto.com/zhuxianzhong/1531748

    總結

    以上是生活随笔為你收集整理的探讨NDK编译错误ld.exe: Dwarf Error: mangled line number section.的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。