[英]clang++: fatal error: 'unistd.h' file not found
Using OS X 10.10.2, I download Clang for Mac OS X v. 3.6.0, and try to compile a simple Hello World program. 使用OS X 10.10.2,我下载了适用于Mac OS X v.3.6.0的Clang ,并尝试编译一个简单的Hello World程序。
The commands I use are these: 我使用的命令是:
(assumes you downloaded clang
to .
) (假设你下载了
clang
.
)
cd .
./clang+llvm-3.6.0-x86_64-apple-darwin/bin/clang++ main.cpp
The result is this: 结果是这样的:
In file included from main.cpp:1:
In file included from ./clang+llvm-3.6.0-x86_64-apple-darwin/bin/../include/c++/v1/iostream:37:
./clang+llvm-3.6.0-x86_64-apple-darwin/bin/../include/c++/v1/__config:23:10: fatal error: 'unistd.h' file not
found
which makes sense, as there is no file unistd.h
, as verifiable by 这是有道理的,因为没有文件
unistd.h
,可以通过验证
find . -name unistd.h
which yields 0
results. 产生
0
结果。
I tried downloading the LibC++ source code v. 3.6.0 but even that contains no unistd.h
. 我尝试下载LibC ++源代码 v.3.6.0,但即使它不包含
unistd.h
。 Where can I find the official/vanilla version of that file, and the files that are referenced, and meta-referenced, by it? 我在哪里可以找到该文件的官方/ vanilla版本,以及由它引用和元引用的文件?
Clang does not include ac library or system headers, you'll need to install Xcode if you want to program on OS X. This page has some more details if you don't want to install the entire Xcode package, you can get away with the command line tools only. Clang不包括交流库或系统头,如果你想在OS X上编程,你需要安装Xcode。如果你不想安装整个Xcode包, 这个页面有更多的细节,你可以逃脱仅限命令行工具。
Once you have Xcode / command line tools installed you can either use the versions of clang and gcc included with Xcode or the one you downloaded, although it's usually easier to use Macports or Homebrew if you're looking to use up to date versions of either. 一旦你安装了Xcode /命令行工具,你可以使用Xcode或你下载的那个版本的clang和gcc,尽管如果你想使用最新版本的任何一个,通常更容易使用Macports或Homebrew 。
That error disappeared after running xcode-select --install
. 运行
xcode-select --install
后,该错误消失了。
(I only keep HomeBrew's LLVM and clang regularly updated, so my original macos headers must have been ancient/non-existent until I used the above command to fix that.) (我只保留HomeBrew的LLVM和clang定期更新,所以我的原始macos标题必须是古老的/不存在的,直到我使用上面的命令来修复它。)
unistd.h
is not a C or a C++ header! unistd.h
不是C或C ++标题! It is a POSIX header. 它是一个POSIX标题。
You could install XCode as it'll come from that, but I honestly don't know whether that'll be at all compatible with the Clang runtime. 您可以安装XCode,因为它来自那里,但老实说我不知道这是否完全与Clang运行时兼容。 I'm not a Mac person.
我不是Mac人。
Perhaps you can find an alternative; 也许你可以找到另一种选择; for example, there's no way you need
unistd.h
to compile a "Hello world" program! 例如, 你不可能需要
unistd.h
来编译一个“Hello world”程序!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.