【发布时间】:2018-03-29 10:17:23
【问题描述】:
请看一下这个简单的C++ 程序:
#include <iostream>
#include <thread>
void thread_test()
{
std::cout << "Thread test\n";
}
int main(int argc, const char * argv[])
{
std::thread t(thread_test);
t.join();
return 0;
}
我正在尝试在 macOS Sierra 上使用 Xcode 编译它。而且它不会编译。上面写着'thread' file not found。
在构建设置中,我将libstdc++ (GNU C++ standard library) 选项用于C++ Standard Library。如果我将此设置切换为libc++ (LLVM C++ standard library with C++11 support),那么没关系,它可以编译。但我的目标是通过使用libstdc++ 而不是libc++ 以某种方式编译它。甚至可能吗?请给我一点建议好吗?
【问题讨论】:
-
你安装的 GCC 版本是什么?
-
这是正确的行为。
std::thread可从 C++11 获得 -
您的确切编译器和链接器命令行是什么?以及编译器/链接器版本?
-
@JesperJuhl 配置为:--prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/ Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1 Apple LLVM 版本 8.1.0 (clang-802.0.42) 目标:x86_64-apple-darwin16.7.0 线程模型: posix InstalledDir:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
-
@Jodocus 配置为:--prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Deve loper/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1 Apple LLVM 版本 8.1.0 (clang-802.0.42) 目标:x86_64 -apple-darwin16.7.0 线程模型:posix InstalledDir:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin –
标签: c++ xcode macos c++11 libstdc++