首页 > 解决方案 > 如何在运行配置命令的地方手动指定 gcc

问题描述

我想在 Mac Mojave 中编译 GNU make,操作系统默认的 c 编译器是 clang。当我运行时:

./configure

输出是:

 dolphins-MacBook-Air:make-3.82 dolphin$ ./configure
    checking for a BSD-compatible install... /usr/local/bin/ginstall -c
    checking whether build environment is sane... yes
    checking for a thread-safe mkdir -p... /usr/local/bin/gmkdir -p
    checking for gawk... no
    checking for mawk... no
    checking for nawk... no
    checking for awk... awk
    checking whether make sets $(MAKE)... yes
    checking for gcc... gcc
    checking whether the C compiler works... no
    configure: error: in `/Users/dolphin/Desktop/make-3.82':
    configure: error: C compiler cannot create executables
    See `config.log' for more details.

安装make时如何指定C编译器?我努力了:

./configure CC=/usr/local/Cellar/gcc@7/7.4.0_2/bin/gcc-7
CC=/usr/local/Cellar/gcc@7/7.4.0_2/bin/gcc-7 ./configure

但它不起作用。

标签: c

解决方案


在 make cli 上尝试一下

$ CC=/usr/local/Cellar/gcc@7/7.4.0_2/bin/gcc-7 make

但首先必须确保 Makefile 已完美生成并重新启动它,这需要make clean


推荐阅读