首页 > 代码库 > unsupported dynamic reloc R_ARM_REL32 AND hidden symbol '__dso_handle' is not defined

unsupported dynamic reloc R_ARM_REL32 AND hidden symbol '__dso_handle' is not defined

项目里编译codec
src\makefiles\android\codec\Makefile
line 25 原本用 4.6 不会报错
-L/data/android/android-ndk/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a \
改成
-L/data/android/android-ndk/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a \

编译报错 (下面只有四行)

make[2]: Entering directory `~/video/makefiles/android/codec/data/android/android-ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -Wl,--as-needed -lc -Wl,--no-undefined -nostdlib -Wl,-soname,libcodec.so -Wl,-shared,-Bsymbolic ../../../src/codec/H264Encoder_noarch_noplat.o ../../../src/codec/ANDROIDAACEncoder_noarch_noplat.o ../../../src/codec/FH264Decoder_noarch_noplat.o ../../../src/codec/AACDecoder_noarch_noplat.o -L. -L../../../output -L../../../input/prebuilt/android -L../../../testbed/recordtest/libs/armeabi -L/data/android/src/4.4/out/target/product/generic/system/lib -L/data/android/android-ndk/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a -lmlbase -laacdec -larcsoft_h264_enc_arm11_vt -larcsoft_mp4audiocommon_he -laacencoder -lavcodec -lavutil -lz -lm -lc -llog -lstagefright -lmedia -lutils -lbinder -lgnustl_static /data/android/android-ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/armv7-a/libgcc.a -shared -fPIC -o ../../../testbed/recordtest/libs/armeabi/libcodec.so -Xlinker -cref -Xlinker -Map -Xlinker ../../../testbed/recordtest/libs/armeabi/libcodec.map/data1/android/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /data/android/android-ndk/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/libgnustl_static.a(eh_globals.o): requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC/data1/android/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: hidden symbol __dso_handle is not defined locallycollect2: error: ld returned 1 exit status

 

相关的库文件是armeabi-v7a文件夹下 libgnustl_static.a
Google上有人解释说所引用crtbegin_so.o非PIC
https://code.google.com/p/android/issues/detail?id=23203
The problem is that there is a text relocation for __dso_handle. In other words, the code in crtbegin_so.o is not position independent.This is what gcc generates for the same code transposed in C, for arm (thumb would be different):

如果一定用4.8的话,按照
http://www.cnblogs.com/yuanxiaoping_21cn_com/p/3971162.html
可以行得通。

unsupported dynamic reloc R_ARM_REL32 AND hidden symbol '__dso_handle' is not defined