我正在尝试编译 XZ-utils 代码以在 Android NDK 中使用。我遵循与正确编译 libogg 和 libtheora 库相同的过程。但是,创建 XZ-Utils 的 liblzma 库不起作用。这是我使用的程序:
1) 转到包含库源的文件夹。
cd ~/Drivers/xz-5.0.5
2)配置Autotool makefile
./configure --prefix=/home/rb/Drivers/xz --host=arm-linux-androideabi --target=arm-linux-androideabi --disable-shared --enable-static --enable-debug
3) 制作库并指定用于编译的工具链(位于/opt/ndk/):
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
运行第三个命令时,出现以下错误:
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/common.c 文件中的一个错误,但我认为这不太可能,因为其他人肯定会更早发现它。有人知道如何为 Android NDK 正确编译 XZ Utils 吗?
更新 我得到了要编译的库,尽管我仍然不知道上述过程有什么问题。通过配置 makefile 进行编译
./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
命令(具有相同的编译器路径)。