C语言 升级到 Mojave 后无法在 Mac 上编译 C 程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/52509602/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't compile C program on a Mac after upgrade to Mojave
提问by Maxxx
I have used the gcc command on the terminal to compile C programs but all of a sudden, after an update to my Mac's OS (to macOS 10.14 Mojave, and XCode 10.0), I started receiving the message:
我在终端上使用 gcc 命令来编译 C 程序,但突然间,在更新到我的 Mac 操作系统(到 macOS 10.14 Mojave 和 XCode 10.0)后,我开始收到消息:
test.c:8:10: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^~~~~~~~~
compilation terminated.
I already have gcc installed as I can find it in /usr/local/binand there really is a gcc in there. I tried running the same file on my other iMac and it worked without any issue.
我已经安装了 gcc,因为我可以在/usr/local/bin其中找到它,并且那里确实有一个 gcc。我尝试在我的其他 iMac 上运行相同的文件,它没有任何问题。
I tried running xcode-select --installand it already was installed, hence it didn't fix the issue I'm having now. I'm guessing that the path is messed up as it doesn't seem like it can find gccafter I started copying and pasting some commands from other resources to solve this issue.
我尝试运行xcode-select --install并且它已经安装,因此它没有解决我现在遇到的问题。我猜是路径搞砸了,因为gcc在我开始从其他资源复制和粘贴一些命令来解决这个问题后,它似乎找不到。
Would like some help on this.
想在这方面提供一些帮助。
回答by Jonathan Leffler
TL;DR
TL; 博士
Make sure you have downloaded the latest 'Command Line Tools' package and run this from a terminal (command line):
确保您已下载最新的“命令行工具”包并从终端(命令行)运行它:
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
For some information on Catalina, see Can't compile a C program on a Mac after upgrading to Catalina 10.15.
有关 Catalina 的一些信息,请参阅升级到 Catalina 10.15 后无法在 Mac 上编译 C 程序。
Extracting a semi-coherent answer from rather extensive comments…
从相当广泛的评论中提取半连贯的答案......
Preamble
前言
Very often, xcode-select --installhas been the correct solution, but it does not seem to help this time. Have you tried running the main Xcode GUI interface? It may install some extra software for you and clean up. I did that after installing Xcode 10.0, but a week or more ago, long before upgrading to Mojave.
很多时候,xcode-select --install一直是正确的解决方案,但这次似乎没有帮助。您是否尝试过运行主 Xcode GUI 界面?它可能会为您安装一些额外的软件并进行清理。我在安装 Xcode 10.0 后这样做了,但一周或更长时间之前,在升级到 Mojave 之前很久。
I observe that if your GCC is installed in /usr/local/bin, you probably aren't using the GCC from Xcode; that's normally installed in /usr/bin.
我观察到,如果您的 GCC 安装在 中/usr/local/bin,则您可能没有使用 Xcode 中的 GCC;通常安装在/usr/bin.
I too have updated to macOS 10.14 Mojave and Xcode 10.0. However, both the system /usr/bin/gccand system /usr/bin/clangare working for me (Apple LLVM version 10.0.0 (clang-1000.11.45.2) Target: x86_64-apple-darwin18.0.0for both.) I have a problem with my home-built GCC 8.2.0 not finding headers in /usr/include, which is parallel to your problem with /usr/local/bin/gccnot finding headers either.
我也更新到 macOS 10.14 Mojave 和 Xcode 10.0。然而,无论是系统/usr/bin/gcc与系统/usr/bin/clang的工作对我来说(Apple LLVM version 10.0.0 (clang-1000.11.45.2) Target: x86_64-apple-darwin18.0.0两个)。我和我的家庭建造的GCC 8.2.0没有找到标题中的问题/usr/include,这是平行于你的问题,/usr/local/bin/gcc没有找到任何标题。
I've done a bit of comparison, and my Mojave machine has no /usr/includeat all, yet /usr/bin/clangis able to compile OK. A header (_stdio.h, with leading underscore) was in my old /usr/include; it is missing now (hence my problem with GCC 8.2.0). I ran xcode-select --installand it said "xcode-select: note: install requested for command line developer tools" and then ran a GUI installer which showed me a licence which I agreed to, and it downloaded and installed the command line tools — or so it claimed.
我做了一些比较,我的 Mojave 机器根本没有/usr/include,但/usr/bin/clang能够编译 OK。标题(_stdio.h,带前导下划线)在我的旧/usr/include; 它现在不见了(因此我对 GCC 8.2.0 有问题)。我跑了xcode-select --install,它说“ xcode-select: note: install requested for command line developer tools”,然后运行一个 GUI 安装程序,它向我展示了我同意的许可证,然后它下载并安装了命令行工具——或者它声称是这样。
I then ran Xcode GUI (command-space, Xcode, return) and it said it needed to install some more software, but still no /usr/include. But I can compile with /usr/bin/clangand /usr/bin/gcc— and the -voption suggests they're using
然后我运行 Xcode GUI(命令空间,Xcode,返回),它说它需要安装更多软件,但仍然没有/usr/include. 但是我可以用/usr/bin/clangand编译/usr/bin/gcc- 并且-v选项表明他们正在使用
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Working solution
工作解决方案
I've found a way. If we are using Xcode 10, you will notice that if you navigate to the
/usrin the Finder, you will not see a folder called 'include' any more, which is why the terminal complains of the absence of the header files which is contained inside the 'include' folder. In the Xcode 10.0 Release Notes, it says there is a package:/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkgand you should install that package to have the
/usr/includefolder installed. Then you should be good to go.
我找到了办法。如果我们使用的是 Xcode 10,您会注意到,如果您导航到
/usrFinder 中的 ,您将不会再看到名为“include”的文件夹,这就是终端抱怨没有包含在其中的头文件的原因“包含”文件夹。在Xcode 10.0 Release Notes 中,它说有一个包:/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg并且您应该安装该软件包以
/usr/include安装文件夹。那么你应该很高兴去。
When all else fails, read the manual or, in this case, the release notes. I'm not dreadfully surprised to find Apple wanting to turn their backs on their Unix heritage, but I am disappointed. If they're careful, they could drive me away. Thank you for the information.
当所有其他方法都失败时,请阅读手册,或者在这种情况下阅读发行说明。发现 Apple 想要背弃他们的 Unix 传统,我并不感到非常惊讶,但我很失望。如果他们小心的话,他们可以把我赶走。感谢您的信息。
Having installed the package using the following command at the command line, I have /usr/includeagain, and my GCC 8.2.0 works once more.
在命令行中使用以下命令安装了软件包后,我/usr/include再次安装了该软件包,并且我的 GCC 8.2.0 再次运行。
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
Downloading Command Line Tools
下载命令行工具
As Vesalpoints out in a valuable comment, you need to download the Command Line Tools package for Xcode 10.1 on Mojave 10.14, and you can do so from:
正如Vesal在一条有价值的评论中指出的那样,您需要在 Mojave 10.14 上下载适用于 Xcode 10.1 的命令行工具包,您可以从:
You need to login with an Apple ID to be able to get the download. When you've done the download, install the Command Line Tools package. Then install the headers as described in the section 'Working Solution'.
您需要使用 Apple ID 登录才能获得下载。完成下载后,安装命令行工具包。然后按照“工作解决方案”部分中的说明安装标头。
This worked for me on Mojave 10.14.1. I must have downloaded this before, but I'd forgotten by the time I was answering this question.
这在 Mojave 10.14.1 上对我有用。我以前一定下载过这个,但在我回答这个问题时我已经忘记了。
Upgrade to Mojave 10.14.4 and Xcode 10.2
升级到 Mojave 10.14.4 和 Xcode 10.2
On or about 2019-05-17, I updated to Mojave 10.14.4, and the Xcode 10.2 command line tools were also upgraded (or Xcode 10.1 command line tools were upgraded to 10.2). The opencommand shown above fixed the missing headers. There may still be adventures to come with upgrading the main Xcode to 10.2 and then re-reinstalling the command line tools and the headers package.
在 2019-05-17 左右,我更新到 Mojave 10.14.4,并且 Xcode 10.2 命令行工具也升级了(或者 Xcode 10.1 命令行工具升级到 10.2)。open上面显示的命令修复了丢失的标题。将主 Xcode 升级到 10.2,然后重新安装命令行工具和 headers 包,可能仍然会有一些冒险。
Upgrade to Xcode 10.3 (for Mojave 10.14.6)
升级到 Xcode 10.3(适用于 Mojave 10.14.6)
On 2019-07-22, I got notice via the App Store that the upgrade to Xcode 10.3 is available and that it includes SDKs for iOS 12.4, tvOS 12.4, watchOS 5.3 and macOS Mojave 10.14.6. I installed it one of my 10.14.5 machines, and ran it, and installed extra components as it suggested, and it seems to have left /usr/includeintact.
2019 年 7 月 22 日,我通过 App Store 收到通知,可以升级到 Xcode 10.3,它包括适用于 iOS 12.4、tvOS 12.4、watchOS 5.3 和 macOS Mojave 10.14.6 的 SDK。我在我的 10.14.5 机器中安装了它,然后运行它,并按照它的建议安装了额外的组件,它似乎/usr/include完好无损。
Later the same day, I discovered that macOS Mojave 10.14.6 was available too (System Preferences ? Software Update), along with a Command Line Utilities package IIRC (it was downloaded and installed automatically). Installing the o/s update did, once more, wipe out /usr/include, but the opencommand at the top of the answer reinstated it again. The date I had on the file for the opencommand was 2019-07-15.
当天晚些时候,我发现 macOS Mojave 10.14.6 也可用(系统偏好设置?软件更新),以及命令行实用程序包 IIRC(它已自动下载并安装)。安装 o/s 更新确实再次清除了/usr/include,但open答案顶部的命令再次恢复了它。我在open命令文件上的日期是 2019 年 7 月 15 日。
Upgrade to XCode 11.0 (for Catalina 10.15)
升级到 XCode 11.0(适用于 Catalina 10.15)
The upgrade to XCode 11.0 ("includes Swift 5.1 and SDKs for iOS 13, tvOS 13, watchOS 6 and macOS Catalina 10.15") was released 2019-09-21. I was notified of 'updates available', and downloaded and installed it onto machines running macOS Mojave 10.14.6 via the App Store app (updates tab) without problems, and without having to futz with /usr/include. Immediately after installation (before having run the application itself), I tried a recompilation and was told:
XCode 11.0 的升级(“包括适用于 iOS 13、tvOS 13、watchOS 6 和 macOS Catalina 10.15 的 Swift 5.1 和 SDK”)于 2019 年 9 月 21 日发布。我收到了“可用更新”的通知,并通过 App Store 应用程序(更新选项卡)将其下载并安装到运行 macOS Mojave 10.14.6 的机器上,没有问题,而且无需使用/usr/include. 安装后立即(在运行应用程序之前),我尝试重新编译并被告知:
Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command.
同意 Xcode/iOS 许可证需要管理员权限,请运行“sudo xcodebuild -license”,然后重试此命令。
Running that (sudo xcodebuild -license) allowed me to run the compiler. Since then, I've run the application to install extra components it needs; still no problem. It remains to be seen what happens when I upgrade to Catalina itself — but my macOS Mojave 10.14.6 machines are both OK at the moment (2019-09-24).
运行那个 ( sudo xcodebuild -license) 允许我运行编译器。从那时起,我运行该应用程序来安装它需要的额外组件;还是没问题。当我升级到 Catalina 本身时会发生什么还有待观察 - 但我的 macOS Mojave 10.14.6 机器目前都可以(2019-09-24)。
回答by Nigel
After trying every answer I could find here and online, I was still getting errors for some missing headers. When trying to compile pyRFR, I was getting errors about stdexceptnot being found, which apparently was not installed in /usr/includewith the other headers. However, I found where it was hiding in Mojave and added this to the end of my ~/.bash_profilefile:
在尝试了我可以在这里和网上找到的所有答案后,我仍然收到一些缺少标题的错误。在尝试编译 pyRFR 时,我收到有关stdexcept未找到的错误,这显然没有/usr/include与其他标头一起安装。但是,我找到了它在 Mojave 中的隐藏位置,并将其添加到我的~/.bash_profile文件末尾:
export CPATH=/Library/Developer/CommandLineTools/usr/include/c++/v1
export CPATH=/Library/Developer/CommandLineTools/usr/include/c++/v1
Having done that, I can now compile pyRFR and other C/C++ programs. According to echo | gcc -E -Wp,-v -, gcc was looking in the old location for these headers (without the /c++/v1), but not the new location, so adding that to CFLAGS fixed it.
完成后,我现在可以编译 pyRFR 和其他 C/C++ 程序。根据echo | gcc -E -Wp,-v -,gcc 正在寻找这些标头的旧位置(没有/c++/v1),而不是新位置,因此将其添加到 CFLAGS 修复了它。
回答by Plattenschieber
When you
当你
- updated to
Mojave 10.14.6 - your
/usr/includewas deleted again - the package mentioned in @Jonathan-lefflers answerdoesn't exist anymore
The file /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg does not exist.and - Xcode complains that command line tools are already installed
xcode-select --install xcode-select: error: command line tools are already installed, use "Software Update" to install updates
- 更新为
Mojave 10.14.6 - 你的
/usr/include又被删了 - @Jonathan-lefflers回答中提到的包不再存在,
The file /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg does not exist.并且 - Xcode 抱怨命令行工具已经安装
xcode-select --install xcode-select: error: command line tools are already installed, use "Software Update" to install updates
Then, what helped me recover the mentioned package, was deleting the whole CommandLineToolsfolder
(sudo) rm -rf /Library/Developer/CommandLineToolsand reinstall it xcode-select --install.
然后,帮助我恢复提到的包的是删除整个CommandLineTools文件夹
(sudo) rm -rf /Library/Developer/CommandLineTools并重新安装它xcode-select --install。
回答by James Rinkevich
The problem is that Xcode, especially Xcode 10.x, has not installed everything, so ensure the command line tools are installed, type this in a terminal shell:
问题是 Xcode,尤其是 Xcode 10.x,还没有安装所有东西,所以请确保安装了命令行工具,在终端 shell 中输入:
xcode-select --install
xcode-select --install
also start Xcode and ensure all the required installation is installed ( you should get prompted if it is not.) and since Xcode 10 does not install the full Mac OS SDK, run the installer at
还要启动 Xcode 并确保安装了所有必需的安装(如果没有,您应该得到提示。)并且由于 Xcode 10 没有安装完整的 Mac OS SDK,请在以下位置运行安装程序
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
as this package is not installed by Xcode 10.
因为这个包不是由 Xcode 10 安装的。
回答by Rob
I've found great solution and explanation at this GitHub comment. The trick:
我在这个GitHub 评论中找到了很好的解决方案和解释。诀窍:
make SDKROOT=`xcrun --show-sdk-path` MACOSX_DEPLOYMENT_TARGET=
Did the job.
做了工作。
回答by JL Peyret
NOTE: The following is likely highly contextual and time-limited before the switch/general availability of macos Catalina 10.15. New laptop. I am writing this Oct 1st, 2019.
注意:以下内容可能在 macos Catalina 10.15 切换/全面可用之前具有高度上下文和时间限制。新的笔记本电脑。我是在 2019 年 10 月 1 日写这篇文章的。
These specific circumstances are, I believe, what caused build problems for me. They may not apply in most other cases.
我相信,这些特定情况是导致我遇到构建问题的原因。它们可能不适用于大多数其他情况。
Context:
语境:
macos 10.14.6 Mojave, Xcode 11.0, right before the launch of macos Catalina 10.15. Newly purchased Macbook Pro.
failure on
pip install psycopg2, which is, basically, a Python package getting compiled from source.I have already carried out a number of the suggested adjustments in the answers given here.
macos 10.14.6 Mojave,Xcode 11.0,就在 macos Catalina 10.15 发布之前。新购买的 Macbook Pro。
失败
pip install psycopg2,基本上是从源代码编译的 Python 包。我已经在此处给出的答案中进行了一些建议的调整。
My errors:
我的错误:
pip install psycopg2
Collecting psycopg2
Using cached https://files.pythonhosted.org/packages/5c/1c/6997288da181277a0c29bc39a5f9143ff20b8c99f2a7d059cfb55163e165/psycopg2-2.8.3.tar.gz
Installing collected packages: psycopg2
Running setup.py install for psycopg2 ... error
ERROR: Command errored out with exit status 1:
command: xxxx/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/bk/_1cwm6dj3h1c0ptrhvr2v7dc0000gs/T/pip-install-z0qca56g/psycopg2/setup.py'"'"'; __file__='"'"'/private/var/folders/bk/_1cwm6dj3h1c0ptrhvr2v7dc0000gs/T/pip-install-z0qca56g/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/bk/_1cwm6dj3h1c0ptrhvr2v7dc0000gs/T/pip-record-ef126d8d/install-record.txt --single-version-externally-managed --compile --install-headers xxx/venv/include/site/python3.6/psycopg2
...
/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -pipe -Os -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -DPSYCOPG_VERSION=2.8.3 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=90615 -DHAVE_LO64=1 -I/Users/jluc/kds2/py2/venv/include -I/opt/local/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -I. -I/opt/local/include/postgresql96 -I/opt/local/include/postgresql96/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.14-x86_64-3.6/psycopg/psycopgmodule.o
clang: warning: no such sysroot directory:
'/Applications/Xcode.app/Contents/Developer/Platforms
?the real error?
/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk' [-Wmissing-sysroot]
In file included from psycopg/psycopgmodule.c:27:
In file included from ./psycopg/psycopg.h:34:
/opt/local/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m/Python.h:25:10: fatal error: 'stdio.h' file not found
? what I thought was the error ?
#include <stdio.h>
^~~~~~~~~
1 error generated.
It appears you are missing some prerequisite to build the package
What I did so far, without fixing anything:
到目前为止我所做的,没有修复任何东西:
xcode-select --install- installed xcode
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
xcode-select --install- 已安装的 xcode
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
Still the same error on stdio.h.
在 stdio.h 上仍然是同样的错误。
which exists in a number of places:
它存在于许多地方:
(venv) jluc@bemyerp$ mdfind -name stdio.h
/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/stdio.h
/usr/include/_stdio.h
/usr/include/secure/_stdio.h
/usr/include/stdio.h ? I believe this is the one that's usually missing.
but I have it.
/usr/include/sys/stdio.h
/usr/include/xlocale/_stdio.h
So, let's go to that first directory clangis complaining about and look:
因此,让我们转到第一个clang抱怨的目录并查看:
(venv) jluc@gotchas$ cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
(venv) jluc@SDKs$ ls -l
total 0
drwxr-xr-x 8 root wheel 256 Aug 29 23:47 MacOSX.sdk
drwxr-xr-x 4 root wheel 128 Aug 29 23:47 DriverKit19.0.sdk
drwxr-xr-x 6 root wheel 192 Sep 11 04:47 ..
lrwxr-xr-x 1 root wheel 10 Oct 1 13:28 MacOSX10.15.sdk -> MacOSX.sdk
drwxr-xr-x 5 root wheel 160 Oct 1 13:34 .
Hah, we have a symlink for MacOSX10.15.sdk, but none for MacOSX10.14.sdk. Here's my first clangerror again:
哈,我们有MacOSX10.15.sdk的符号链接,但没有MacOSX10.14.sdk的符号链接。这是我的第一个clang错误:
clang: warning: no such sysroot directory: '/Applications/Xcode.app/.../Developer/SDKs/MacOSX10.14.sdk' [-Wmissing-sysroot]
clang: warning: no such sysroot directory: '/Applications/Xcode.app/.../Developer/SDKs/MacOSX10.14.sdk' [-Wmissing-sysroot]
My guess is Apple jumped the gun on their xcode config and are already thinking they're on Catalina. Since it's a new Mac, the old config for 10.14 is not in place.
我的猜测是 Apple 在他们的 xcode 配置上大放异彩,并且已经认为他们在 Catalina 上。由于是新 Mac,10.14 的旧配置没有到位。
THE FIX:
修复:
Let's symlink 10.14 the same way as 10.15:
让我们以与 10.15 相同的方式符号链接 10.14:
ln -s MacOSX.sdk/ MacOSX10.14.sdk
ln -s MacOSX.sdk/ MacOSX10.14.sdk
btw, if I go to that sdk directory, I find:
顺便说一句,如果我去那个 sdk 目录,我会发现:
...
./usr/include/sys/stdio.h
./usr/include/stdio.h
....
OUTCOME:
结果:
pip install psycopg2works.
pip install psycopg2作品。
Note: the actual pip install command made no reference to MacOSX10.14.sdk, that came at a later point, possibly by the Python installation mechanism introspecting the OS version.
注意:实际的 pip install 命令没有引用MacOSX10.14.sdk,这可能是由于 Python 安装机制对操作系统版本的反省。
回答by bitbrane
Be sure to check Xcode Preferences -> Locations.
请务必检查 Xcode Preferences -> Locations。
The Command Line Tools I had selected was for the previous version of Xcode (8.2.1 instead of 10.1)
我选择的命令行工具适用于先前版本的 Xcode(8.2.1 而不是 10.1)
回答by mlo55
Had similar problems as the OP
与 OP 有类似的问题
Issue
问题
cat hello.c
猫你好.c
#include <stdlib.h>
int main() { exit(0); }
clang hello.c
叮当你好.c
/usr/local/include/stdint.h:2:10: error: #include nested too deeply
etc...
Attempted fix
尝试修复
I installed the latest version of XCode, however, release notes indicated the file mentioned in the previous fix, from Jonathan here, was no longer available.
我安装了最新版本的 XCode,但是,发行说明表明先前修复中提到的文件(来自 Jonathan 此处)不再可用。
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
Details here https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes, under the New Featuressection.
此处的详细信息 https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes,在新功能部分下。
Solution that worked for me...
对我有用的解决方案......
Using details in this comment, https://github.com/SOHU-Co/kafka-node/issues/881#issuecomment-396197724
使用此评论中的详细信息,https://github.com/SOHU-Co/kafka-node/issues/881#issuecomment-396197724
I found that brew doctorreported I had unused includes in my /usr/local/folder.
我发现brew doctor报告说我的/usr/local/文件夹中有未使用的包含。
So to fix, I used the command provided by user HowCrazy, to find the unused includes and move them to a temporary folder.
所以为了修复,我使用了用户HowCrazy提供的命令来查找未使用的包含并将它们移动到一个临时文件夹。
Repeated here...
这里重复...
mkdir /tmp/includes
brew doctor 2>&1 | grep "/usr/local/include" | awk '{=;print}' | xargs -I _ mv _ /tmp/includes
After running the scripts, the include file issue was gone. nb: I commented on this issue heretoo.
运行脚本后,包含文件问题消失了。注意:我也在这里评论过这个问题。
回答by Sergio Pulgarin
I was having this issue and nothing worked. I ran xcode-select --installand also installed /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg.
我遇到了这个问题,但没有任何效果。我运行xcode-select --install并安装了/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg.
BACKGROUND
背景
Since I was having issues with App Storeon a new laptop, I was forced to download the Xcode Betainstaller from the Apple website to install Xcode outside App Store. So I only had Xcode Betainstalled.
由于我在新笔记本电脑上使用App Store时遇到问题,我被迫从 Apple 网站下载Xcode Beta安装程序,以便在App Store之外安装 Xcode 。所以我只安装了Xcode Beta。
SOLUTION
解决方案
This, (I think), was making clangto not find the SDKROOTdirectory /Applications/Xcode.app/...., because there is no Betain the path, or maybe Xcode Betasimply doesn't install it (I don't know).
To fix the issue, I had to remove Xcode Betaand resolve the App Storeissue to install the release version.
这(我认为)是因为clang找不到SDKROOT目录/Applications/Xcode.app/....,因为Beta路径中没有,或者Xcode Beta根本没有安装它(我不知道)。为了解决这个问题,我必须删除Xcode Beta并解决App Store问题才能安装发布版本。
tldr;
tldr;
If you have Xcode Beta, try cleaning up everything and installing the release version before trying out the solutions that are working for other people.
如果您有Xcode Beta,请尝试清理所有内容并安装发布版本,然后再尝试适用于其他人的解决方案。
回答by Mak
I tried almost all the posted solutions and nothing worked for me. I use Mojave OS (10.14.6) and what finally worked for me (after removing and re-installing Xcode and CLTs and SDK headers):
我尝试了几乎所有已发布的解决方案,但没有任何效果对我有用。我使用 Mojave OS (10.14.6) 以及最终对我有用的东西(在删除并重新安装 Xcode 和 CLT 以及 SDK 标头之后):
- Install Clang v8 from https://cran.r-project.org/bin/macosx/tools/
- Modify the following lines from ~/.R/Makevars file
- 从https://cran.r-project.org/bin/macosx/tools/安装 Clang v8
- 修改 ~/.R/Makevars 文件中的以下几行
CC=/usr/local/opt/llvm/bin/clang -fopenmp
CXX=/usr/local/opt/llvm/bin/clang++
with
和
CC=/usr/local/clang8/bin/clang -fopenmp
CXX=/usr/local/clang8/bin/clang++
Now R packages that rely on C compilers install successfully
现在依赖 C 编译器的 R 包安装成功

