2015-06-30 127 views
2

我試圖爲所有體系結構(包括64位)編譯lib。 我創建的腳本適用於armeabi,armeabi-v7a,arm64-v8a和x86。 它失敗了mips,並可能會失敗的mips64以及,但我不關心他們;它是次要的,我有主要問題:我關心x86_64,這個不會編譯。爲Android x86_64編譯libav

編輯:x86也失敗了。在帖子結尾編譯錯誤日誌。

下面是該腳本:

  1. 創建一個獨立的工具鏈:就像一個魅力
  2. 使用該工具鏈配置的lib:

./configure --arch=x86_64 --cpu=x86_64 --cross-prefix=/some/path/usingLibAV/toolchains/x86_64/bin/x86_64-linux-android- --target-os=android --sysroot="/some/path/Library/Android/ndk/platforms/android-21/arch-x86_64/" --extra-cflags=" -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 -march=atom -ffast-math -msse3 -mfpmath=sse " --extra-ldflags="-Wl,-rpath-link=/some/path/Library/Android/ndk/platforms/android-21/arch-x86_64//usr/lib -L/some/path/Library/Android/ndk/platforms/android-21/arch-x86_64//usr/lib -nostdlib -lc -lm" --enable-shared --disable-symver

這似乎配置好,config.log不會引發任何錯誤,除了下面的警告(無論如何我都會得到這個警告):

WARNING: /some/path/Documents/usingLibAV/toolchains/x86_64/bin/x86_64-linux-android-pkg-config not found, library detection may fail. 
  1. compile:make -j 8.我得到.so文件正確生成,但如果我仔細看看日誌,我會在最後得到錯誤(對不起,噸粘貼整個日誌,它是長):

CC libswscale/yuv2rgb.o AR libavformat/libavformat.a YASM libswscale/x86/scale.o AR libavcodec/libavcodec.a AR libavresample/libavresample.a AR libavutil/libavutil.a CC avconv.o CC cmdutils.o CC avconv_opt.o CC avconv_filter.o CC avprobe.o HOSTCC doc/print_options.o AR libavdevice/libavdevice.a LD libavutil/libavutil.so.54 AR libavfilter/libavfilter.a /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libc.so while searching for c /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libm.so while searching for m /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libm.so while searching for m /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libz.so while searching for z LD libavresample/libavresample.so.2 /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libc.so while searching for c /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libm.so while searching for m /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libm.so while searching for m /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libz.so while searching for z LD libavcodec/libavcodec.so.56 HOSTLD doc/print_options GENTEXI doc/avoptions_format.texi GENTEXI doc/avoptions_codec.texi POD doc/avprobe.pod POD doc/avconv.pod MAN doc/avprobe.1 MAN doc/avconv.1 /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libc.so while searching for c /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libm.so while searching for m /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libm.so while searching for m /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libz.so while searching for z LD libavformat/libavformat.so.56 /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libc.so while searching for c /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libm.so while searching for m /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libm.so while searching for m /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libz.so while searching for z LD libavdevice/libavdevice.so.55 /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libc.so while searching for c /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libm.so while searching for m /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libm.so while searching for m /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libz.so while searching for z LD libswscale/libswscale.so.3 AR libswscale/libswscale.a /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libc.so while searching for c /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libm.so while searching for m /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libm.so while searching for m /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libz.so while searching for z LD libavfilter/libavfilter.so.5 /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libc.so while searching for c /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libm.so while searching for m /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libm.so while searching for m /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libz.so while searching for z LD avconv LD avprobe /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libc.so while searching for c /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libm.so while searching for m /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libm.so while searching for m /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libz.so while searching for z libavcodec/libavcodec.so: error: undefined reference to '__powidf2' collect2: error: ld returned 1 exit status make: * [avprobe] Error 1 make: * Waiting for unfinished jobs.... /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libc.so while searching for c /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libm.so while searching for m /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libm.so while searching for m /Volumes/diskE/some/path/usingLibAV/toolchains/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld: warning: skipping incompatible /some/pathLibrary/Android/ndk/platforms/android-21/arch-x86_64//usr/lib/libz.so while searching for z libavcodec/libavcodec.so: error: undefined reference to '__powidf2' collect2: error: ld returned 1 exit status make: *** [avconv] Error 1

錯誤編譯86,與配置後:的./configure --arch = 86 --cpu = 86 --cross前綴= /一些/ path/Documents/usingLibAV/toolchains/x86/bin/i686-linux-android- --target-os = android --sysroot =「/ some/path/Library/Android/ndk/platforms/android-9/arch- x86 /「--extra-cflags =」-O3 -fpic -DANDROID -DHAVE_SYS_UIO_H = 1 -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing - finline-limit = 300 -march = atom -fast-math -msse3 -mfpmath = sse「--extra-ldflags =」 - Wl,-rpath-link =/some/path/Library/Android/ndk/platforms/android- 9/arch-x86 // usr/lib -L ​​/ some/path/Library/Android/ndk/platforms/android-9/arch-x86 // usr/lib -nostdlib -lc -lm「--enable-shared

       ^
CC libswscale/x86/yuv2rgb.o 
CC libswscale/yuv2rgb.o 
AR libavformat/libavformat.a 
YASM libswscale/x86/scale.o 
AR libavcodec/libavcodec.a 
AR libavresample/libavresample.a 
AR libavutil/libavutil.a 
CC avconv.o 
CC cmdutils.o 
CC avconv_opt.o 
CC avconv_filter.o 
CC avprobe.o 
HOSTCC doc/print_options.o 
AR libavdevice/libavdevice.a 
LD libavutil/libavutil.so.54 
AR libavfilter/libavfilter.a 
HOSTLD doc/print_options 
LD libavresample/libavresample.so.2 
GENTEXI doc/avoptions_format.texi 
GENTEXI doc/avoptions_codec.texi 
POD doc/avprobe.pod 
POD doc/avconv.pod 
LD libavcodec/libavcodec.so.56 
MAN doc/avprobe.1 
MAN doc/avconv.1 
LD libavformat/libavformat.so.56 
LD libavdevice/libavdevice.so.55 
LD libswscale/libswscale.so.3 
AR libswscale/libswscale.a 
LD libavfilter/libavfilter.so.5 
LD avconv 
LD avprobe 
libavdevice/libavdevice.so: error: undefined reference to '__divdi3' 
libavdevice/libavdevice.so:libavdevice/libavdevice.so: errorerror: undefined reference to ': __moddi3' 
libavformatundefined reference to '__moddi3' 
libavformat/libavformat.so/libavformat.so: error: undefined reference: error to : undefined'__udivdi3' reference to '__udivdi3' 
libavformat/ 
libavformat/libavformat.so: errorlibavformat.so: error: : undefined reference undefined referenceto ' to '__umoddi3' 
libavcodec/__umoddi3' 
libavcodec.so: errorlibavcodec/: libavcodec.so: error: undefined reference to '__powidf2' 
avconv.c:1434: error: undefined referenceundefined reference to '__powidf2 to ' 
'__divdi3' 
avconv.c:1441: error: undefined reference to '__divdi3' 
avconv.c:1434: error: undefined reference to '__divdi3' 
avconv.c:1441: error: undefined reference to '__divdi3' 
collect2: error: ld returned 1 exit status 
collect2: error: ld returned 1 exit status 
make: *** [avprobe] Error 1 
make: *** Waiting for unfinished jobs.... 
make: *** [avconv] Error 1 

回答

1

您沒有指定任何--cross-prefix--cc,這意味着它會使用你的主機系統的編譯器(OS X)編譯爲Android - 這個時候,它會連接到Android庫實際上只失敗。

要實際按預期工作,請在配置行中添加--cross-prefix=x86_64-linux-android-。 (我假設你做了這樣的事情,以使其適用於其他體系結構。)

編輯:我誤讀了,你實際上提供--cross-prefix就好。

刪除所有的--extra-cflags--extra-ldflags - 它們是多餘的和衝突的。如果你對他們有任何具體的需求或情況,那麼你可能會重新考慮添加一些單獨的標誌,但其中大多數都是多餘的。在這種情況下,指向你的sysroot的lib目錄的-L選項似乎會導致你的問題 - 通過--sysroot已經足夠了,-L-Wl,-rpath-link只是多餘的。

一般來說,不要盲目添加大量的選項 - 當涉及到編譯器選項時,不會更好。只添加你具體理解並知道你需要的那些。

如果您使用--target-os=android,則不需要--disable-symver - 只有在android被添加爲--target-os的單獨值之前,才需要該選項。

+0

感謝您的快速回復。你是對的,我用--cross-prefix作爲其他曲拱。但在我看來,我也是爲x86_64做的:--cross-prefix =/some/path/usingLibAV/toolchains/x86_64/bin/x86_64-linux-android-或者我想念你的觀點? – user2346922

+0

噢,對不起,我不知何故錯過了你的使用(特別是當這篇文章的原始版本討論了你的主機系統編譯器的版本時)。我試過你的命令行,然後用一個實際可行的解決方案編輯答案。 – mstorsjo

+0

它適用於x86,x86_64甚至mips!謝謝 !然而,編譯時我仍然得到mips64的錯誤: /var/folders/pk/x0zcs6n571372r3x0yq38pfc0005y7/T//ccel6m70.s:彙編信息: /var/folders/pk/x0zcs6n571372r3x0yq38pfc0005y7/T//ccel6m70.s:96:錯誤:此處理器不支持opco​​de:mips64r6(mips64r6)'lwl $ 4,3($ 2)'有什麼想法? – user2346922