libtool : X--tag=CC: command not found 编译报错

解决libtool编译错误
本文介绍了解决GCC编译时遇到的libtool错误的方法,包括更新libtool脚本、修改aclocal.m4文件和调整libtool脚本中的变量。

GCC编译代码时,执行./configure在代码目录下生成了libtool脚本,再执行make 出现类似以下错误

 

 

Error代码   收藏代码
  1. ../libtool: line 832: X--tag=CC: command not found  
  2. ../libtool: line 865: libtool: ignoring unknown tag : command not found  
  3. ../libtool: line 832: X--mode=compile: command not found  
  4. ../libtool: line 998: *** Warning: inferring the mode of operation is deprecated.: command not found  
  5. ../libtool: line 999: *** Future versions of Libtool will require --mode=MODE be specified.: command not found  
  6. ../libtool: line 1142: Xgcc: command not found  
  7. ../libtool: line 1142: X-DHAVE_CONFIG_H: command not found  
  8. ../libtool: line 1142: X-I.: command not found  
  9. ../libtool: line 1142: X-I../include: No such file or directory  
  10. ../libtool: line 1142: X-g: command not found  
  11. ../libtool: line 1142: X-I/usr/local/include: No such file or directory  
  12. ../libtool: line 1142: X-g: command not found  
  13. ../libtool: line 1142: X-O2: command not found  
  14. ../libtool: line 1142: X-MT: command not found  
  15. ../libtool: line 1142: Xargs.lo: command not found  
  16. ../libtool: line 1142: X-MD: command not found  
  17. ../libtool: line 1142: X-MP: command not found  
  18. ../libtool: line 1142: X-MF: command not found  
  19. ../libtool: line 1142: X.deps/args.Tpo: No such file or directory  
  20. ../libtool: line 1142: X-c: command not found  
  21. ../libtool: line 1193: Xargs.lo: command not found  
  22. ../libtool: line 1198: libtool: compile: cannot determine name of library object from `': command not found  
Error代码   收藏代码
  1. ../libtool: line 832: X--tag=CC: command not found  
  2. ../libtool: line 865: libtool: ignoring unknown tag : command not found  
  3. ../libtool: line 832: X--mode=compile: command not found  
  4. ../libtool: line 998: *** Warning: inferring the mode of operation is deprecated.: command not found  
  5. ../libtool: line 999: *** Future versions of Libtool will require --mode=MODE be specified.: command not found  
  6. ../libtool: line 1142: Xgcc: command not found  
  7. ../libtool: line 1142: X-DHAVE_CONFIG_H: command not found  
  8. ../libtool: line 1142: X-I.: command not found  
  9. ../libtool: line 1142: X-I../include: No such file or directory  
  10. ../libtool: line 1142: X-g: command not found  
  11. ../libtool: line 1142: X-I/usr/local/include: No such file or directory  
  12. ../libtool: line 1142: X-g: command not found  
  13. ../libtool: line 1142: X-O2: command not found  
  14. ../libtool: line 1142: X-MT: command not found  
  15. ../libtool: line 1142: Xargs.lo: command not found  
  16. ../libtool: line 1142: X-MD: command not found  
  17. ../libtool: line 1142: X-MP: command not found  
  18. ../libtool: line 1142: X-MF: command not found  
  19. ../libtool: line 1142: X.deps/args.Tpo: No such file or directory  
  20. ../libtool: line 1142: X-c: command not found  
  21. ../libtool: line 1193: Xargs.lo: command not found  
  22. ../libtool: line 1198: libtool: compile: cannot determine name of library object from `': command not found  

 

原因据说是因为在项目目录下生成的libtool脚本中定义了$ECHO变量,但是在脚本文件ltmain.sh中,使用的却是$echo(生成的libtool版本太旧)

打开aclocal.m4文件,可以在很前面的一段配置中找到这么两句

 

Config代码   收藏代码
  1. # This can be used to rebuild libtool when needed  
  2. LIBTOOL_DEPS="$ltmain"  
  3.   
  4. # Always use our own libtool.  
  5. LIBTOOL='$(SHELL) $(top_builddir)/libtool'  
  6. AC_SUBST(LIBTOOL)dnl  
Config代码   收藏代码
  1. # This can be used to rebuild libtool when needed  
  2. LIBTOOL_DEPS="$ltmain"  
  3.   
  4. # Always use our own libtool.  
  5. LIBTOOL='$(SHELL) $(top_builddir)/libtool'  
  6. AC_SUBST(LIBTOOL)dnl  
 

 

可通过以下方法解决:

 

1. 直接复制系统自带的libtool到项目目录,应该在/usr/bin目录下,覆盖代码文件目录下的libtool,再执行make

(没装就apt-get install libtool 或者 yum install libtool 安装一下吧)

 

2.  修改aclocal.m4文件,将上面的LIBTOOL='$(SHELL) $(top_builddir)/libtool'改成LIBTOOL='$(SHELL)  /usr/bin/libtool'后重新执行./configure

 

3. 将源码目录下libtool脚本中所有的$ECHO替换成$echo. 或者将脚本文件ltmain.sh里的$echo替换成$ECHO,都一样,重新执行./configure

 

转载注明源 http://asyty.iteye.com/blog/1487299

sudo make install Making install in libfcgi make[1]: Entering directory '/home/yk/fcgi-2.4.1-SNAP-0910052249/libfcgi' make[2]: Entering directory '/home/yk/fcgi-2.4.1-SNAP-0910052249/libfcgi' test -z "/home/yk/fcgi/lib" || mkdir -p -- "/home/yk/fcgi/lib" /bin/bash ../libtool --mode=install /usr/bin/install -c 'libfcgi.la' '/home/yk/fcgi/lib/libfcgi.la' /usr/bin/install -c .libs/libfcgi.so.0.0.0 /home/yk/fcgi/lib/libfcgi.so.0.0.0 (cd /home/yk/fcgi/lib && { ln -s -f libfcgi.so.0.0.0 libfcgi.so.0 || { rm -f libfcgi.so.0 && ln -s libfcgi.so.0.0.0 libfcgi.so.0; }; }) (cd /home/yk/fcgi/lib && { ln -s -f libfcgi.so.0.0.0 libfcgi.so || { rm -f libfcgi.so && ln -s libfcgi.so.0.0.0 libfcgi.so; }; }) /usr/bin/install -c .libs/libfcgi.lai /home/yk/fcgi/lib/libfcgi.la /usr/bin/install -c .libs/libfcgi.a /home/yk/fcgi/lib/libfcgi.a chmod 644 /home/yk/fcgi/lib/libfcgi.a arm-xilinx-linux-gnueabi-ranlib /home/yk/fcgi/lib/libfcgi.a ../libtool: line 6556: arm-xilinx-linux-gnueabi-ranlib: command not found /bin/bash ../libtool --mode=install /usr/bin/install -c 'libfcgi++.la' '/home/yk/fcgi/lib/libfcgi++.la' libtool: install: warning: relinking `libfcgi++.la' (cd /home/yk/fcgi-2.4.1-SNAP-0910052249/libfcgi; /bin/bash ../libtool --tag=CXX --mode=relink arm-xilinx-linux-gnueabi-g++ -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/home/yk/sdk/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi -O2 -pipe -g -feliminate-unused-debug-types -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o libfcgi++.la -lfcgi -rpath /home/yk/fcgi/lib fcgio.lo ) arm-xilinx-linux-gnueabi-g++ -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/home/yk/sdk/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi -shared -nostdlib /home/yk/sdk/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi/usr/lib/crti.o /home/yk/sdk/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi/usr/lib/arm-xilinx-linux-gnueabi/8.2.0/crtbeginS.o .libs/fcgio.o -Wl,--rpath -Wl,/home/yk/fcgi/lib -L/home/yk/fcgi/lib -lfcgi -L/home/yk/sdk/sysroots/x86_64-petalinux-linux/usr/lib/arm-xilinx-linux-gnueabi/gcc/arm-xilinx-linux-gnueabi/8.2.0 -L/home/yk/sdk/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi/lib -L/home/yk/sdk/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi/usr/lib/arm-xilinx-linux-gnueabi/8.2.0 -L/home/yk/sdk/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi/usr/lib -lstdc++ -lm -lc -lgcc_s /home/yk/sdk/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi/usr/lib/arm-xilinx-linux-gnueabi/8.2.0/crtendS.o /home/yk/sdk/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi/usr/lib/crtn.o -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-soname -Wl,libfcgi++.so.0 -o .libs/libfcgi++.so.0.0.0 ../libtool: line 4501: arm-xilinx-linux-gnueabi-g++: command not found libtool: install: error: relink `libfcgi++.la' with the above command before installing it Makefile:256: recipe for target 'install-libLTLIBRARIES' failed make[2]: *** [install-libLTLIBRARIES] Error 1 make[2]: Leaving directory '/home/yk/fcgi-2.4.1-SNAP-0910052249/libfcgi' Makefile:459: recipe for target 'install-am' failed make[1]: *** [install-am] Error 2 make[1]: Leaving directory '/home/yk/fcgi-2.4.1-SNAP-0910052249/libfcgi' Makefile:373: recipe for target 'install-recursive' failed make: *** [install-recursive] Error 1
07-21
在使用 `libtool` 编译时出现的 `aarch64-linux-gnu-gcc: command not found` 错误,通常表示系统无法找到指定的交叉编译器。以下是解决此问题的几种方法: ### 确保交叉编译工具链已正确安装 首先检查系统中是否已安装 `aarch64-linux-gnu-gcc` 工具链。在基于 Debian 的系统上,可以通过以下命令安装: ```bash sudo apt-get install gcc-aarch64-linux-gnu ``` 该命令将安装适用于 ARM64 架构的交叉编译工具链,包括 `aarch64-linux-gnu-gcc` 和 `aarch64-linux-gnu-g++`[^3]。 ### 验证编译器路径是否已加入环境变量 即使工具链已经安装,如果系统仍然报错command not found”,可能是因为编译器路径未被加入到系统的 `PATH` 环境变量中。可以使用以下命令检查是否存在该编译器: ```bash which aarch64-linux-gnu-gcc ``` 如果返回空结果,则需要手动将交叉编译器的安装路径添加到 `PATH` 中。例如,假设工具链安装在 `/usr/bin/` 目录下,可以在终端执行: ```bash export PATH=/usr/bin:$PATH ``` 对于更复杂的构建环境,可能需要修改 `/etc/sudoers` 文件中的 `secure_path` 设置,以确保 `sudo` 执行时也能识别交叉编译器的路径: ```bash Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin ``` 这样可以确保 `make` 或 `configure` 使用 `sudo` 运行时也能访问到交叉编译器[^4]。 ### 检查 libtool 配置和调用方式 在某些情况下,`libtool` 可能会缓存旧的编译器路径或配置信息。为避免此类问题,在重新构建项目前应先运行以下命令清理构建环境: ```bash make clean ``` 此外,还可以尝试手动指定 `CC` 和 `CXX` 环境变量,确保 `libtool` 调用正确的编译器。例如,在配置阶段指定: ```bash CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ ./configure --host=aarch64-linux-gnu ``` 这种方法可以覆盖默认的编译器设置,确保 `libtool` 正确调用交叉编译器[^1]。 ### 示例:完整的配置与编译流程 以下是一个完整的配置和编译示例,适用于交叉编译场景: ```bash # 安装必要的依赖项 sudo apt-get install gcc-aarch64-linux-gnu automake autoconf libtool # 设置交叉编译器路径 export CC=aarch64-linux-gnu-gcc export CXX=aarch64-linux-gnu-g++ export PATH=/usr/bin:$PATH # 配置项目并指定交叉编译参数 ./configure --host=aarch64-linux-gnu --prefix=/opt/myproject # 清理之前的构建文件 make clean # 开始编译 make -j$(nproc) # 安装编译结果 sudo make install ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值