2014-06-24 73 views
0

我正在嘗試構建x264庫,以便在我使用jni在Android上加載的共享庫中使用它。我能夠創造一切作爲一個可執行沒有任何錯誤,但是當我建立一個共享庫我與R_ARM_MOVW_ABS_NC的動態重定位錯誤:Android JNI x264作爲庫提供重定位R_ARM_MOVW_ABS_NC;使用-fPIC重新編譯

[armeabi-v7a] SharedLibrary : libx264.so 
/home/martin/bin/android-ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /home/martin/Documents/Sources/ScreenSharingServer/app/src/main/obj/local/armeabi-v7a/objs/x264/common/arm/pixel-a.o: requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC 
/home/martin/bin/android-ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /home/martin/Documents/Sources/ScreenSharingServer/app/src/main/obj/local/armeabi-v7a/objs/x264/common/arm/mc-a.o: requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC 
/home/martin/bin/android-ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /home/martin/Documents/Sources/ScreenSharingServer/app/src/main/obj/local/armeabi-v7a/objs/x264/common/arm/dct-a.o: requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC 
/home/martin/bin/android-ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /home/martin/Documents/Sources/ScreenSharingServer/app/src/main/obj/local/armeabi-v7a/objs/x264/common/arm/quant-a.o: requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC 
/home/martin/bin/android-ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /home/martin/Documents/Sources/ScreenSharingServer/app/src/main/obj/local/armeabi-v7a/objs/x264/common/arm/predict-a.o: requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC 
collect2: error: ld returned 1 exit status 
make: *** [/home/martin/Documents/Sources/ScreenSharingServer/app/src/main/obj/local/armeabi-v7a/libx264.so] Error 1 

這裏是我的android.mk:

LOCAL_PATH := $(my-dir) 

include $(CLEAR_VARS) 

APP_ABI := armeabi armeabi-v7a 
TARGET_ARCH_ABI := armeabi-v7a 
LOCAL_ARM_NEON := true 
ARCH_ARM_HAVE_NEON := true 

AM_CFLAGS := -march=armv7-a -mfpu=neon 
AM_CCASFLAGS := -march=armv7-a -mfpu=neon 

LOCAL_SRC_FILES:= common/mc.c common/predict.c common/pixel.c common/macroblock.c \ 
     common/frame.c common/dct.c common/cpu.c common/cabac.c \ 
     common/common.c common/osdep.c common/rectangle.c \ 
     common/set.c common/quant.c common/deblock.c common/vlc.c \ 
     common/mvpred.c common/bitstream.c \ 
     encoder/analyse.c encoder/me.c encoder/ratecontrol.c \ 
     encoder/set.c encoder/macroblock.c encoder/cabac.c \ 
     encoder/cavlc.c encoder/encoder.c encoder/lookahead.c \ 
     common/threadpool.c \ 
     common/arm/mc-c.c common/arm/predict-c.c \ 
     x264.c \ 
     common/arm/cpu-a.S common/arm/pixel-a.S common/arm/mc-a.S \ 
     common/arm/dct-a.S common/arm/quant-a.S common/arm/deblock-a.S \ 
     common/arm/predict-a.S 

LOCAL_SHARED_LIBRARIES := libcutils 
LOCAL_STATIC_LIBRARIES := swscale 

LOCAL_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/.. 
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/.. 

LOCAL_CFLAGS := -fPIC -O3 -ffast-math -fstrict-aliasing -DANDROID -std=c99 
LOCAL_CPPFLAGS := -fPIC 
LOCAL_LDFLAGS := -lm 
LOCAL_MODULE := x264 

include $(BUILD_SHARED_LIBRARY) 

當我建立與V = 1我看到-fPIC選項在每個彙編行...

我不知道是否有人可以幫助我瞭解我做錯了什麼。

謝謝你的時間!

馬丁

回答

1

所有有問題的對象文件(例如定量-AO)來自裝配文件(定量-AS) 望着從http://git.videolan.org/?p=x264.git;a=tree;f=common/arm;h=64e8990fc2043750599c45593f1bc7698d94048a;hb=refs/heads/master大會來源,它看起來像你應該在規定的PIC宏您config.h

正常情況下,如果您使用「./configure --enable-pic ...」,則通過x264腳本完成 我猜你正在使用自定義的config.h,如果是這樣一個'#定義PIC 1',或者簡單地添加-DPIC = 1到你的LOCAL_CFLAGS

希望這個h ELPS。

+0

OMG非常感謝,我沒有看到... – MoAdiB

相關問題