arm-eabi-gcc: error trying to exec 'cc1': execvp: No such file or directory

编android源码的时候总是会报下面的错误~~最后发现是交叉编译工具的权限问题,chmod -R 777 * 就可以了

arm-eabi-gcc: error trying to exec 'cc1': execvp: No such file or directory

总结一下:

1、确认cc1是存在的

2、确认交叉编译工具的权限

bell@bell-virtual-machine:~/nm/openwrt-15.05.1$ make V=s -j4 make[1]: Entering directory '/home/bell/nm/openwrt-15.05.1' make[2]: Entering directory '/home/bell/nm/openwrt-15.05.1' make[2]: Entering directory '/home/bell/nm/openwrt-15.05.1' + mkdir -p /home/bell/nm/openwrt-15.05.1/staging_dir/target-arm_mpcore+vfp_uClibc-0.9.33.2_eabi + mkdir -p /home/bell/nm/openwrt-15.05.1/staging_dir/host + cd /home/bell/nm/openwrt-15.05.1/staging_dir/target-arm_mpcore+vfp_uClibc-0.9.33.2_eabi + mkdir -p bin lib include stamp + cd /home/bell/nm/openwrt-15.05.1/staging_dir/host + mkdir -p bin lib include stamp mkdir -p /home/bell/nm/openwrt-15.05.1/build_dir/target-arm_mpcore+vfp_uClibc-0.9.33.2_eabi/stamp mkdir -p /home/bell/nm/openwrt-15.05.1/build_dir/host/stamp /home/bell/nm/openwrt-15.05.1/staging_dir/host/include/sys touch /home/bell/nm/openwrt-15.05.1/staging_dir/target-arm_mpcore+vfp_uClibc-0.9.33.2_eabi/.prepared install -m0644 /home/bell/nm/openwrt-15.05.1/tools/include/*.h /home/bell/nm/openwrt-15.05.1/staging_dir/host/include/ install -m0644 /home/bell/nm/openwrt-15.05.1/tools/include/sys/*.h /home/bell/nm/openwrt-15.05.1/staging_dir/host/include/sys/ ln -sf lib /home/bell/nm/openwrt-15.05.1/staging_dir/host/lib64 touch /home/bell/nm/openwrt-15.05.1/staging_dir/host/.prepared make[3]: Entering directory '/home/bell/nm/openwrt-15.05.1/tools/patch' make[3]: Entering directory '/home/bell/nm/openwrt-15.05.1/tools/make-ext4fs' make[3]: Entering directory '/home/bell/nm/openwrt-15.05.1/tools/sstrip' rm -rf /home/bell/nm/openwrt-15.05.1/staging_dir/target-arm_mpcore+vfp_uClibc-0.9.33.2_eabi/root-realview make[2]: Leaving directory '/home/bell/nm/openwrt-15.05.1' make[3]: Entering directory '/home/bell/nm/openwrt-15.05.1/tools/firmware-utils' gcc -O2 -I/home/bell/nm/openwrt-15.05.1/staging_dir/host/include -I/home/bell/nm/openwrt-15.05.1/staging_dir/host/usr/include -include endian.h -o /home/bell/nm/openwrt-15.05.1/build_dir/host/sstrip/sstrip src/sstrip.c gcc: error trying to exec 'cc1': execvp: No such file or directory Makefile:25: recipe for target '/home/bell/nm/openwrt-15.05.1/build_dir/host/sstrip/.built' failed make[3]: *** [/home/bell/nm/openwrt-15.05.1/build_dir/host/sstrip/.built] Error 1 make[3]: Leaving directory '/home/bell/nm/openwrt-15.05.1/tools/sstrip' tools/Makefile:122: recipe for target 'tools/sstrip/compile' failed make[2]: *** [tools/sstrip/compile] Error 2 make[2]: *** Waiting for unfinished jobs.... (cd /home/bell/nm/openwrt-15.05.1/build_dir/host/patch-2.7.5/; if [ -x configure ]; then cp -fpR /home/bell/nm/openwrt-15.05.1/scripts/config.{guess,sub} /home/bell/nm/openwrt-15.05.1/build_dir/host/patch-2.7.5// && bash ./configure CC="gcc" CFLAGS="-O2 -I/home/bell/nm/openwrt-15.05.1/staging_dir/host/include -I/home/bell/nm/openwrt-15.05.1/staging_dir/host/usr/include" CPPFLAGS="-I/home/bell/nm/openwrt-15.05.1/staging_dir/host/include -I/home/bell/nm/openwrt-15.05.1/staging_dir/host/usr/include" LDFLAGS="-L/home/bell/nm/openwrt-15.05.1/staging_dir/host/lib -L/home/bell/nm/openwrt-15.05.1/staging_dir/host/usr/lib" SHELL="/usr/bin/env bash" --target=x86_64-linux-gnu --host=x86_64-linux-gnu --build=x86_64-linux-gnu --program-prefix="" --program-suffix="" --prefix=/home/bell/nm/openwrt-15.05.1/staging_dir/host --exec-prefix=/home/bell/nm/openwrt-15.05.1/staging_dir/host --sysconfdir=/home/bell/nm/openwrt-15.05.1/staging_dir/host/etc --localstatedir=/home/bell/nm/openwrt-15.05.1/staging_dir/host/var --sbindir=/home/bell/nm/openwrt-15.05.1/staging_dir/host/bin ; fi ) make[3]: Leaving directory '/home/bell/nm/openwrt-15.05.1/tools/make-ext4fs' mkdir -p /home/bell/nm/openwrt-15.05.1/build_dir/host/firmware-utils/bin gcc -O2 -I/home/bell/nm/openwrt-15.05.1/staging_dir/host/include -I/home/bell/nm/openwrt-15.05.1/staging_dir/host/usr/include -include endian.h -L/home/bell/nm/openwrt-15.05.1/staging_dir/host/lib -L/home/bell/nm/openwrt-15.05.1/staging_dir/host/usr/lib -o /home/bell/nm/openwrt-15.05.1/build_dir/host/firmware-utils/bin/addpattern src/addpattern.c gcc: error trying to exec 'cc1': execvp: No such file or directory Makefile:82: recipe for target '/home/bell/nm/openwrt-15.05.1/build_dir/host/firmware-utils/.built' failed make[3]: *** [/home/bell/nm/openwrt-15.05.1/build_dir/host/firmware-utils/.built] Error 1 make[3]: Leaving directory '/home/bell/nm/openwrt-15.05.1/tools/firmware-utils' tools/Makefile:122: recipe for target 'tools/firmware-utils/compile' failed make[2]: *** [tools/firmware-utils/compile] Error 2 checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking whether make supports nested variables... (cached) yes checking for x86_64-linux-gnu-gcc... gcc checking whether the C compiler works... no configure: error: in `/home/bell/nm/openwrt-15.05.1/build_dir/host/patch-2.7.5': configure: error: C compiler cannot create executables See `config.log' for more details Makefile:21: recipe for target '/home/bell/nm/openwrt-15.05.1/build_dir/host/patch-2.7.5/.configured' failed make[3]: *** [/home/bell/nm/openwrt-15.05.1/build_dir/host/patch-2.7.5/.configured] Error 77 make[3]: Leaving directory '/home/bell/nm/openwrt-15.05.1/tools/patch' tools/Makefile:122: recipe for target 'tools/patch/compile' failed make[2]: *** [tools/patch/compile] Error 2 make[2]: Leaving directory '/home/bell/nm/openwrt-15.05.1' tools/Makefile:121: recipe for target '/home/bell/nm/openwrt-15.05.1/staging_dir/target-arm_mpcore+vfp_uClibc-0.9.33.2_eabi/stamp/.tools_install_yynyynynynyyyyyyyyynyyyyyyyyynyyyyynnyyynnyynnnyy' failed make[1]: *** [/home/bell/nm/openwrt-15.05.1/staging_dir/target-arm_mpcore+vfp_uClibc-0.9.33.2_eabi/stamp/.tools_install_yynyynynynyyyyyyyyynyyyyyyyyynyyyyynnyyynnyynnnyy] Error 2 make[1]: Leaving directory '/home/bell/nm/openwrt-15.05.1' Build failed - please re-run with -j1 to see the real error message /home/bell/nm/openwrt-15.05.1/include/toplevel.mk:181: recipe for target 'world' failed make: *** [world] Error 1 既然cc1在,为啥编译时会如上报错
08-07
<think>好的,我现在需要解决用户提到的关于arm-none-eabi-gcc编译时出现的“cannot execute cc1”错误的问题。用户提供的引用信息中有几个类似的问题,我需要结合这些信息来分析可能的原因和解决方案。 首先,用户引用了几个关于gccg++出现无法执行cc1pluscc1错误的案例。例如,引用[2]中提到在配置环境时出现类似的错误,引用[4]则指出可能存在多个编译器版本冲突的问题。这些线索提示我需要检查以下几个方面: 1. **编译器安装是否完整**:cc1GCC的前端组件,如果安装过程中损坏缺失,可能导致此错误。用户是否完整安装了arm-none-eabi-gcc工具链?可能需要重新安装检查安装包完整性。 2. **路径和环境变量问题**:GCC在调用cc1时,需要正确找到该组件的路径。如果环境变量设置不正确,者路径中有其他冲突的版本,可能导致找不到cc1。例如,引用[4]提到系统中可能存在多个编译器cc1的实例,导致路径混乱。 3. **权限问题**:cc1文件的执行权限是否被正确设置?如果权限不足,编译器无法执行该组件,也会引发错误。 4. **架构兼容性**:用户是否在正确的操作系统架构上运行编译器?例如,是否在x86系统上错误地安装了ARM工具链,者反之? 接下来,我需要根据这些可能性逐步提出解决方案。首先建议用户检查安装完整性,重新安装工具链可能解决文件缺失的问题。其次,检查PATH环境变量,确保编译器路径正确,并且没有其他路径干扰。然后,确认cc1文件的存在及其权限。最后,考虑交叉编译环境的兼容性。 此外,用户的问题可能涉及到交叉编译工具链的配置,因此需要确保所有依赖项都已安装,例如必要的32位库(如果宿主系统是64位的)。例如,在某些Linux发行版上,安装multilib支持可能是必要的。 总结可能的解决步骤: 1. 重新安装arm-none-eabi-gcc工具链,确保安装过程无错误。 2. 验证工具链的安装路径是否在环境变量PATH中,并检查是否存在多个版本冲突。 3. 确认cc1文件的路径,并检查其执行权限。 4. 安装所需的兼容性库,如32位库。 5. 检查系统日志使用strace跟踪编译过程,查找更详细的错误信息。 需要将这些步骤以清晰的方式呈现给用户,同时参考提供的引用资料,特别是引用[4]中提到的关于多个编译器实例的冲突问题,提示用户检查系统中是否有重复安装的工具链。此外,引用[2]和[3]中的情况也提醒用户注意环境配置的正确性,确保所有依赖项满足。</think>### 解决 arm-none-eabi-gcc 编译时出现 "cannot execute cc1" 错误的方法 #### 1. 验证编译器安装完整性 **原因**: 编译器工具链可能未正确安装组件缺失(如`cc1`文件未正确部署)[^4]。 **解决方法**: - 重新安装 `arm-none-eabi-gcc` 工具链,建议从官方渠道(如ARM官网包管理器)下载。 - 使用包管理器安装时,确认安装命令包含完整组件。例如在Ubuntu中: ```bash sudo apt-get install --reinstall arm-none-eabi-gcc arm-none-eabi-binutils ``` #### 2. 检查路径冲突与环境变量 **原因**: 系统可能存在多个编译器版本环境变量配置错误,导致调用错误的路径。 **解决方法**: - 确认工具链安装路径已添加到 `PATH` 环境变量中。例如,若工具链安装在 `/usr/bin/arm-none-eabi-gcc`,需确保该路径优先级高于其他冲突路径。 - 使用 `which arm-none-eabi-gcc` 检查实际调用的编译器路径。 - 若存在多个版本,删除冗余版本通过 `update-alternatives` 配置默认版本。 #### 3. 确认 `cc1` 文件权限与存在性 **原因**: `cc1` 组件可能因权限不足无法执行,文件损坏丢失。 **解决方法**: - 查找 `cc1` 文件路径(通常在 `/usr/lib/gcc/arm-none-eabi/<版本>/cc1`)。 - 检查文件权限: ```bash ls -l /usr/lib/gcc/arm-none-eabi/*/cc1 chmod +x /usr/lib/gcc/arm-none-eabi/*/cc1 # 若无执行权限 ``` -文件缺失,重新安装工具链。 #### 4. 安装兼容性依赖库 **原因**: 缺少32位运行库(常见于64位系统)[^2][^3]。 **解决方法**: - 在Ubuntu/Debian中安装32位支持库: ```bash sudo apt-get install gcc-multilib lib32z1 ``` #### 5. 调试与日志分析 **原因**: 系统调用错误可能隐藏更深层次的问题。 **解决方法**: - 使用 `strace` 跟踪编译过程: ```bash strace -f arm-none-eabi-gcc -c test.c 2>&1 | grep cc1 ``` - 检查输出中 `execve` 调用是否指向正确的 `cc1` 路径。 --- ### 相关问题 1. **如何检查交叉编译工具链的安装路径是否正确?** *提示*: 使用 `which` 命令检查环境变量 `PATH`。 2. **交叉编译时出现动态链接库错误该如何解决?** *提示*: 需确认目标架构与宿主系统的库兼容性,可能需要静态链接安装目标架构的库。 3. **如何为ARM开发配置VSCode的调试环境?** *提示*: 需要安装插件(如Cortex-Debug)并配置 `.vscode/launch.json`。 --- ### 引用说明 - 关于多版本编译器冲突的解决方案参考了路径管理建议[^4]。 - 依赖库缺失问题借鉴了32位兼容库的安装方法[^2]。 - 权限和文件完整性检查是解决此类编译问题的通用步骤[^1]。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值