使用arm-linux-gnueabihf交叉编译ncurses时make install报错求助
解决交叉编译ncurses时strip格式识别错误的问题
问题重现
交叉编译ncurses 6.4到arm-linux-gnueabihf架构时,执行make install出现以下错误:
strip: Unable to recognise the format of the input file `/home/chumeng/cross_compile/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-tic' /usr/bin/install: strip process terminated abnormally make[1]: *** [Makefile:219: install.progs] Error 1 make: *** [Makefile:136: install] Error 2
使用的configure命令:
./configure --prefix=/home/chumeng/cross_compile/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf --target=arm-linux-gnueabihf --host=arm-linux-gnueabihf --with-shared --with-normal --without-debug --without-ada --enable-widec --enable-pc-files --with-cxx-binding --with-cxx-shared --enable-ext-colors --enable-ext-mouse --enable-overwrite
错误原因
主机系统默认的/usr/bin/strip是x86架构工具,无法识别交叉编译生成的ARM架构二进制文件(如arm-linux-gnueabihf-tic),导致strip命令执行失败。
解决方法
方法1:安装时指定交叉工具链的strip
直接在make install命令中显式指定交叉工具链配套的strip:
make install STRIP=arm-linux-gnueabihf-strip
若交叉工具链不在系统PATH中,需填写完整路径:
make install STRIP=/home/chumeng/cross_compile/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-strip
方法2:configure阶段提前指定strip
如果还未执行编译,可在configure时就配置好交叉strip路径:
./configure --prefix=/home/chumeng/cross_compile/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf --target=arm-linux-gnueabihf --host=arm-linux-gnueabihf --with-shared --with-normal --without-debug --without-ada --enable-widec --enable-pc-files --with-cxx-binding --with-cxx-shared --enable-ext-colors --enable-ext-mouse --enable-overwrite --with-strip=arm-linux-gnueabihf-strip
之后正常执行make -j32和make install即可。
方法3:临时跳过strip步骤
若暂时不需要二进制文件的strip优化,可直接禁用安装时的strip操作:
make install INSTALL_STRIP_FLAG=
安装完成后,可手动用交叉strip处理生成的二进制文件:
arm-linux-gnueabihf-strip /home/chumeng/cross_compile/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-*
内容的提问来源于stack exchange,提问作者李昊泽
相关产品推荐
相关产品推荐

