我正在尝试使用 Android NDK 编译适用于 Android 的 binutils,因此我使用找到的指南安装了 NDK这里(特别是“高级方法”),我通过成功编译 Lua 来证明它是有效的。
以下是我遵循的步骤:
export NDK=/path/to/ndk
export SYSROOT=$NDK/platforms/android-23/arch-arm
$NDK/build/tools/make_standalone_toolchain.py --arch=arm --api=23 --install-dir /tmp/android-toolchain
export PATH=/tmp/android-toolchain/bin:$PATH
mkdir build-binutils
cd binutils
export TARGET=arm-linux-androideabi
export HOST=$TARGET
export BUILD=x86_64-linux
../binutils-2.27/configure --host=$HOST --target=$TARGET --build=$BUILD --with-sysroot=$SYSROOT --disable-nls --disable-werror
make
make install
make install
失败并显示以下输出:
This is not dpkg install-info anymore, but GNU install-info
See the man page for ginstall-info for command line arguments
./libtool: line 1118: arm-linux-androideabi-ranlib: command not found
make[5]: *** [install-bfdlibLTLIBRARIES] Error 127
make[4]: *** [install-am] Error 2
make[3]: *** [install-recursive] Error 1
make[2]: *** [install] Error 2
make[1]: *** [install-bfd] Error 2
make: *** [install] Error 2
请注意,运行arm-linux-androideabi-ranlib
效果很好:
$ arm-linux-androideabi-ranlib
Usage: arm-linux-androideabi-ranlib [options] archive
Generate an index to speed access to archives
The options are:
@<file> Read options from <file>
--plugin <name> Load the specified plugin
-D Use zero for symbol map timestamp
-U Use actual symbol map timestamp (default)
-t Update the archive's symbol map timestamp
-h --help Print this help message
-v --version Print version information
arm-linux-androideabi-ranlib: supported targets: elf32-littlearm elf32- bigarm elf32-little elf32-big plugin srec symbolsrec verilog tekhex binary ihex
安装交叉编译工具链的正确方法是什么?
答案1
我找到了罪魁祸首:我实际上是在运行sudo make install
而不是在运行make install
,因此由于用户切换而忽略了临时路径。解决方案是运行sudo su
然后更新 PATH 并重新运行make install