【发布时间】:2019-04-01 23:49:33
【问题描述】:
我对 MacOS 环境还很陌生,之前在编译 C 脚本时遇到了一些问题。我遇到了以下问题:
fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
我尝试重新安装xcode-select --install,但一直告诉我
xcode-select: error: 命令行工具已安装,使用“软件更新”安装更新
我更新了所有内容,但什么也没有。显然是因为我没有/usr/includes 文件。我找到了一种使用
/Library/Developer/CommandLineTools/usr/bin/g++ XXXX.cpp
但是,现在我正在尝试 ./compile 和 make 另一个软件,但我不知道如何默认使用这个 gcc 解释器。当我尝试 ./configure 时出现此错误
配置:错误:无法运行 C 编译程序。如果你打算 交叉编译,使用'--host'。有关详细信息,请参阅“config.log”
所以当我查看config.log 时:
configure:3224: checking for gcc
configure:3240: found /usr/local/bin/gcc
configure:3251: result: gcc
configure:3282: checking for C compiler version
configure:3291: gcc --version >&5
gcc (GCC) 4.9.2 20141029 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
configure:3302: $? = 0
configure:3291: gcc -v >&5
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/lto-wrapper
Target: x86_64-apple-darwin14.0.0
Configured with: ../gcc-4.9-20141029/configure --enable-languages=c++,fortran
Thread model: posix
gcc version 4.9.2 20141029 (prerelease) (GCC)
configure:3302: $? = 0
configure:3291: gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:3302: $? = 1
configure:3291: gcc -qversion >&5
gcc: error: unrecognized command line option '-qversion'
gcc: fatal error: no input files
compilation terminated.
configure:3302: $? = 1
configure:3322: checking whether the C compiler works
configure:3344: gcc conftest.c >&5
configure:3348: $? = 0
configure:3396: result: yes
configure:3399: checking for C compiler default output file name
configure:3401: result: a.out
configure:3407: checking for suffix of executables
configure:3414: gcc -o conftest conftest.c >&5
configure:3418: $? = 0
configure:3440: result:
configure:3462: checking whether we are cross compiling
configure:3470: gcc -o conftest conftest.c >&5
conftest.c:15:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
configure:3474: $? = 1
configure:3481: ./conftest
./configure: line 3483: ./conftest: No such file or directory
configure:3485: $? = 127
configure:3492: error: in `/Users/XXXX/phyml':
configure:3494: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
您对我如何解决它有任何想法吗?
非常感谢!
【问题讨论】:
-
/usr/includes文件不是东西;你的意思是说你没有/usr/include文件夹?如果是这样……那是怎么发生的? -
是的,对不起,我在谈论 /usr/include 文件夹。因为我没有它,所以我不知道它是“包含”还是“包含”.. 但是是的,我不明白.. 我非常想回到 Linux,但我不能.. 这个 xcode东西不会重新安装 /usr/include 文件夹:/
-
可以this 帮忙吗? (实际上不要删除,只是将它们移动到某个地方以防万一)
-
感谢您的帮助,但我已经尝试过了,但它不起作用!我又试了一遍,还是不行。我也尝试了“sudo gem install xcode-install”,但仍然没有完成这项工作..:/
标签: c macos compiler-errors