首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为Android编译XZ

为Android编译XZ
EN

Stack Overflow用户
提问于 2013-09-17 15:34:41
回答 2查看 2K关注 0票数 0

我正在尝试编译XZ-utils代码,以便在Android中使用。我遵循与正确编译libogg和libtheora库相同的过程。但是,它不能创建XZ的liblzma库。这是我使用的程序:

1)转到包含库源的文件夹。

代码语言:javascript
复制
cd ~/Drivers/xz-5.0.5

2)将Autotool makefile配置为

代码语言:javascript
复制
./configure --prefix=/home/rb/Drivers/xz --host=arm-linux-androideabi --target=arm-linux-androideabi --disable-shared --enable-static --enable-debug

3)创建库并指定用于编译的工具链(位于/opt/ndk/中):

代码语言:javascript
复制
make CC=/opt/ndk/arm-linux-androideabi-4.4.3/bin/arm-linux-androideabi-gcc CXX=/opt/ndk/arm-linux-androideabi-4.4.3/bin/arm-linux-androideabi-g++ LD=/opt/ndk/arm-linux-androideabi-4.4.3/bin/arm-linux-androideabi-ld

在运行第三个命令时,我得到以下错误:

代码语言:javascript
复制
make  all-recursive
make[1]: Entering directory `/home/rb/Drivers/xz-5.0.5'
Making all in src
make[2]: Entering directory `/home/rb/Drivers/xz-5.0.5/src'
Making all in liblzma
make[3]: Entering directory `/home/rb/Drivers/xz-5.0.5/src/liblzma'
Making all in api
make[4]: Entering directory `/home/rb/Drivers/xz-5.0.5/src/liblzma/api'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/home/rb/Drivers/xz-5.0.5/src/liblzma/api'
make[4]: Entering directory `/home/rb/Drivers/xz-5.0.5/src/liblzma'
/bin/bash ../../libtool  --tag=CC   --mode=compile /opt/ndk/arm-linux-androideabi-4.4.3/bin/arm-linux-androideabi-gcc -DHAVE_CONFIG_H -I. -I../..  -I../../src/liblzma/api -I../../src/liblzma/common -I../../src/liblzma/check -I../../src/liblzma/lz -I../../src/liblzma/rangecoder -I../../src/liblzma/lzma -I../../src/liblzma/delta -I../../src/liblzma/simple -I../../src/common -DTUKLIB_SYMBOL_PREFIX=lzma_  -pthread -fvisibility=hidden -Wall -Wextra -Wvla -Wformat=2 -Winit-self -Wmissing-include-dirs -Wstrict-aliasing -Wfloat-equal -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wmissing-noreturn -Wredundant-decls -g -O2 -MT liblzma_la-tuklib_physmem.lo -MD -MP -MF .deps/liblzma_la-tuklib_physmem.Tpo -c -o liblzma_la-tuklib_physmem.lo `test -f '../../src/common/tuklib_physmem.c' || echo './'`../../src/common/tuklib_physmem.c
libtool: compile:  /opt/ndk/arm-linux-androideabi-4.4.3/bin/arm-linux-androideabi-gcc -DHAVE_CONFIG_H -I. -I../.. -I../../src/liblzma/api -I../../src/liblzma/common -I../../src/liblzma/check -I../../src/liblzma/lz -I../../src/liblzma/rangecoder -I../../src/liblzma/lzma -I../../src/liblzma/delta -I../../src/liblzma/simple -I../../src/common -DTUKLIB_SYMBOL_PREFIX=lzma_ -pthread -fvisibility=hidden -Wall -Wextra -Wvla -Wformat=2 -Winit-self -Wmissing-include-dirs -Wstrict-aliasing -Wfloat-equal -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wmissing-noreturn -Wredundant-decls -g -O2 -MT liblzma_la-tuklib_physmem.lo -MD -MP -MF .deps/liblzma_la-tuklib_physmem.Tpo -c ../../src/common/tuklib_physmem.c -o liblzma_la-tuklib_physmem.o
mv -f .deps/liblzma_la-tuklib_physmem.Tpo .deps/liblzma_la-tuklib_physmem.Plo
/bin/bash ../../libtool  --tag=CC   --mode=compile /opt/ndk/arm-linux-androideabi-4.4.3/bin/arm-linux-androideabi-gcc -DHAVE_CONFIG_H -I. -I../..  -I../../src/liblzma/api -I../../src/liblzma/common -I../../src/liblzma/check -I../../src/liblzma/lz -I../../src/liblzma/rangecoder -I../../src/liblzma/lzma -I../../src/liblzma/delta -I../../src/liblzma/simple -I../../src/common -DTUKLIB_SYMBOL_PREFIX=lzma_  -pthread -fvisibility=hidden -Wall -Wextra -Wvla -Wformat=2 -Winit-self -Wmissing-include-dirs -Wstrict-aliasing -Wfloat-equal -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wmissing-noreturn -Wredundant-decls -g -O2 -MT liblzma_la-common.lo -MD -MP -MF .deps/liblzma_la-common.Tpo -c -o liblzma_la-common.lo `test -f 'common/common.c' || echo './'`common/common.c
libtool: compile:  /opt/ndk/arm-linux-androideabi-4.4.3/bin/arm-linux-androideabi-gcc -DHAVE_CONFIG_H -I. -I../.. -I../../src/liblzma/api -I../../src/liblzma/common -I../../src/liblzma/check -I../../src/liblzma/lz -I../../src/liblzma/rangecoder -I../../src/liblzma/lzma -I../../src/liblzma/delta -I../../src/liblzma/simple -I../../src/common -DTUKLIB_SYMBOL_PREFIX=lzma_ -pthread -fvisibility=hidden -Wall -Wextra -Wvla -Wformat=2 -Winit-self -Wmissing-include-dirs -Wstrict-aliasing -Wfloat-equal -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wmissing-noreturn -Wredundant-decls -g -O2 -MT liblzma_la-common.lo -MD -MP -MF .deps/liblzma_la-common.Tpo -c common/common.c -o liblzma_la-common.o
In file included from common/common.c:13:
common/common.h:92: error: expected ';', ',' or ')' before 'in'
common/common.h:135: error: expected specifier-qualifier-list before 'lzma_code_function'
common/common.h:238: error: expected ';', ',' or ')' before 'in'
common/common.c:73: error: expected ';', ',' or ')' before 'in'
common/common.c: In function 'lzma_next_filter_update':
common/common.c:114: error: 'lzma_next_coder' has no member named 'update'
common/common.c:115: error: 'lzma_next_coder' has no member named 'update'
common/common.c: In function 'lzma_next_end':
common/common.c:126: error: 'lzma_next_coder' has no member named 'end'
common/common.c:127: error: 'lzma_next_coder' has no member named 'end'
common/common.c:133: error: unknown field 'code' specified in initializer
common/common.c:133: warning: initialization makes integer from pointer without a cast
common/common.c:133: warning: initialized field overwritten
common/common.c:133: warning: (near initialization for '(anonymous).init')
common/common.c:133: warning: initialized field overwritten
common/common.c:133: warning: (near initialization for '(anonymous).init')
common/common.c:133: error: unknown field 'end' specified in initializer
common/common.c:133: warning: excess elements in struct initializer
common/common.c:133: warning: (near initialization for '(anonymous)')
common/common.c:133: error: unknown field 'get_check' specified in initializer
common/common.c:133: warning: excess elements in struct initializer
common/common.c:133: warning: (near initialization for '(anonymous)')
common/common.c:133: error: unknown field 'memconfig' specified in initializer
common/common.c:133: warning: excess elements in struct initializer
common/common.c:133: warning: (near initialization for '(anonymous)')
common/common.c:133: error: unknown field 'update' specified in initializer
common/common.c:133: warning: excess elements in struct initializer
common/common.c:133: warning: (near initialization for '(anonymous)')
common/common.c: In function 'lzma_strm_init':
common/common.c:156: error: unknown field 'code' specified in initializer
common/common.c:156: warning: initialization makes integer from pointer without a cast
common/common.c:156: warning: initialized field overwritten
common/common.c:156: warning: (near initialization for '(anonymous).init')
common/common.c:156: warning: initialized field overwritten
common/common.c:156: warning: (near initialization for '(anonymous).init')
common/common.c:156: error: unknown field 'end' specified in initializer
common/common.c:156: warning: excess elements in struct initializer
common/common.c:156: warning: (near initialization for '(anonymous)')
common/common.c:156: error: unknown field 'get_check' specified in initializer
common/common.c:156: warning: excess elements in struct initializer
common/common.c:156: warning: (near initialization for '(anonymous)')
common/common.c:156: error: unknown field 'memconfig' specified in initializer
common/common.c:156: warning: excess elements in struct initializer
common/common.c:156: warning: (near initialization for '(anonymous)')
common/common.c:156: error: unknown field 'update' specified in initializer
common/common.c:156: warning: excess elements in struct initializer
common/common.c:156: warning: (near initialization for '(anonymous)')
common/common.c: In function 'lzma_code':
common/common.c:180: error: 'lzma_next_coder' has no member named 'code'
common/common.c:253: error: 'lzma_next_coder' has no member named 'code'
common/common.c: In function 'lzma_get_check':
common/common.c:331: error: 'lzma_next_coder' has no member named 'get_check'
common/common.c:334: error: 'lzma_next_coder' has no member named 'get_check'
common/common.c: In function 'lzma_memusage':
common/common.c:345: error: 'lzma_next_coder' has no member named 'memconfig'
common/common.c:346: error: 'lzma_next_coder' has no member named 'memconfig'
common/common.c: In function 'lzma_memlimit_get':
common/common.c:362: error: 'lzma_next_coder' has no member named 'memconfig'
common/common.c:363: error: 'lzma_next_coder' has no member named 'memconfig'
common/common.c: In function 'lzma_memlimit_set':
common/common.c:380: error: 'lzma_next_coder' has no member named 'memconfig'
common/common.c:386: error: 'lzma_next_coder' has no member named 'memconfig'
make[4]: *** [liblzma_la-common.lo] Error 1
make[4]: Leaving directory `/home/rb/Drivers/xz-5.0.5/src/liblzma'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/rb/Drivers/xz-5.0.5/src/liblzma'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/rb/Drivers/xz-5.0.5/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/rb/Drivers/xz-5.0.5'
make: *** [all] Error 2

我不知道是什么导致了这个错误,或者更重要的是,如何解决这个错误。我寻找这些错误,但找不到解决办法。对我来说,这似乎是源代码的公共/Common.c文件中的一个错误,但我认为这是不太可能的,因为其他人肯定会更早地找到它。有人知道如何正确编译用于Android的XZ吗?

UPDATE我已经编译了这个库,尽管我仍然不知道上面的过程有什么问题。通过将makefile配置为

代码语言:javascript
复制
./configure --prefix=/home/rb/Drivers/xz --host=arm-linux-androideabi --target=arm-linux-androideabi --enable-static --with-pic --disable-xz --disable-xzdec --disable-lzmainfo --disable-scripts --disable-lzmadec --disable-shared

make命令不同,我直接使用了make install命令(具有相同的编译器路径)。

EN

回答 2

Stack Overflow用户

发布于 2018-12-26 15:41:31

构建XZ的步骤

您可以通过运行以下命令从其git下载XZ:

代码语言:javascript
复制
git clone https://git.tukaani.org/xz.git

前者在为各种体系结构构建时非常有用;因此,您可以运行(在源目录中):

代码语言:javascript
复制
git clean -dfx
./autogen.sh

我的NDK位于/home/osboxes/dev/Androd-NDK-r16b中,因此我通过运行以下命令将其划分为3种体系结构:

代码语言:javascript
复制
cd /home/osboxes/dev
~/dev/android-ndk-r16b/build/tools/make-standalone-toolchain.sh --use-llvm --arch=arm --install-dir=android-ndk-arm --force
~/dev/android-ndk-r16b/build/tools/make-standalone-toolchain.sh --use-llvm --arch=x86 --install-dir=android-ndk-x86 --force
~/dev/android-ndk-r16b/build/tools/make-standalone-toolchain.sh --use-llvm --arch=arm64 --install-dir=android-ndk-arm64 --force

臂用

代码语言:javascript
复制
CC=~/dev/android-ndk-arm/bin/clang CFLAGS="-fPIE" LDFLAGS="-pie" ./configure --prefix=/home/osboxes/dev/libs/arm --host=arm-linux-androideabi --target=arm-linux-androideabi --enable-static --disable-xz --disable-xzdec --disable-lzmainfo --disable-scripts --disable-lzmadec --disable-shared

对于ARM64

代码语言:javascript
复制
CC=~/dev/android-ndk-arm64/bin/clang CFLAGS="-fPIE" LDFLAGS="-pie" ./configure --prefix=/home/osboxes/dev/libs/arm64 --host=aarch64-linux-android --target=aarch64-linux-android --enable-static --with-pic --disable-xz --disable-xzdec --disable-lzmainfo --disable-scripts --disable-lzmadec --disable-shared

对于x86

代码语言:javascript
复制
CC=~/dev/android-ndk-x86/bin/clang CFLAGS="-fPIE" LDFLAGS="-pie" ./configure --prefix=/home/osboxes/dev/libs/x86 --host=i686-linux-android --target=i686-linux-android --enable-static --disable-xz --disable-xzdec --disable-lzmainfo --disable-scripts --disable-lzmadec --disable-shared

在每个配置之后,您必须运行:

代码语言:javascript
复制
make -j2

选项"-j2“使用2 CPU构建进程。您可以更改要使用的CPU数量,甚至可以删除此选项。若要安装已编译的源代码,请运行:

代码语言:javascript
复制
make install
票数 2
EN

Stack Overflow用户

发布于 2013-11-07 12:35:44

只需将配置的CC指向交叉编译器,并将其编译为静态的。不要使用任何其他标志。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18854053

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档