gpt4 book ai didi

c - 苹果操作系统 "configure: error: cannot run C compiled programs"

转载 作者:太空狗 更新时间:2023-10-29 17:09:12 28 4
gpt4 key购买 nike

我是 MacOS 环境的新手,之前在编译 C 脚本时遇到了一些问题。我遇到了以下问题:

fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.

我尝试重新安装 xcode-select --install 但一直告诉我

xcode-select: error: command line tools are already installed, use "Software Update" to install updates

我更新了所有内容,但什么也没更新。显然是因为我没有 /usr/includes 文件。我找到了一种使用

编译我的软件的方法

/Library/Developer/CommandLineTools/usr/bin/g++ XXXX.cpp

但是,现在我正在尝试./compilemake 另一个软件,但我不知道如何默认使用这个gcc 解释器。当我尝试 ./configure 时出现此错误

configure: error: cannot run C compiled programs. If you meant to cross compile, use '--host'. See 'config.log' for more details

所以当我查看 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

您对我如何修复它有任何想法吗?

非常感谢!

最佳答案

在这个问题的小评论中,真的很容易错过melpomene的回答,所以我把这个贴在这里,让大家看看。此错误通常意味着您缺少已从 Xcode 中删除的编译器工具(实际上是 header )。

您可以在 /Library/Developer/CommandLineTools/Packages/ 中找到它们,因为它们的名称可能会有所不同,具体取决于您将来的 macOS 版本。

假设您正在运行 macOS Mojave (10.14),您需要运行:

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

然后 macOS 风格的软件包安装程序将启动,要求您提供管理员密码。这是 Apple 官方软件包,虽然从随机目录安装某些东西可能很奇怪,但您可以相信它。不过你不必相信我的话。 Apple 在 Xcode 10 发行说明中隐藏了此更改,您可以在此处找到他们的解释:https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes#3035623

我将在此处重现此链接以防该链接消失或更改:

The Command Line Tools package installs the macOS system headers inside the macOS SDK. Software that compiles with the installed tools will search for headers within the macOS SDK provided by either Xcode at:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk

or the Command Line Tools at:

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

depending on which is selected using xcode-select.

The command line tools will search the SDK for system headers by default. However, some software may fail to build correctly against the SDK and require macOS headers to be installed in the base system under /usr/include. If you are the maintainer of such software, we encourage you to update your project to work with the SDK or file a bug report for issues that are preventing you from doing so. As a workaround, an extra package is provided which will install the headers to the base system. In a future release, this package will no longer be provided. You can find this package at:

/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg 
> To make sure that you're using the intended version of the command line tools, run xcode-select -s or xcode select -s /Library/Developer/CommandLineTools after installing.

关于c - 苹果操作系统 "configure: error: cannot run C compiled programs",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53038856/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com