运行 Ubuntu 16.04 下的协程示例给出“'experimental/coroutine' 找不到文件”
Running the coroutines example under Ubuntu 16.04 gives "'experimental/coroutine' file not found"
查看 clang-5.0 release notes it says that "C++ coroutines TS has landed", and suggests to check out this example 以开始使用。我显然可以 运行 在线示例,所以我决定在我的 Ubuntu Server 16.04 Xenial 机器上尝试。
我刚刚尝试了全新安装
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-5.0 main"
sudo apt-get update
sudo apt-get install -y clang-5.0 libc++-dev
然后直奔
clang++-5.0 -Wall -Wextra -std=gnu++2a "-fcoroutines-ts" "-stdlib=libc++" -o test.out test.cpp
(test.cpp
是 the aforementioned example 的复制粘贴)
然而,我只是得到
coroutines.cpp:2:10: fatal error: 'experimental/coroutine' file not found
#include <experimental/coroutine>
所以我可以想象我遗漏了一些东西,无论是安装还是编译标志。我试图在网上查找,但找不到任何有用的东西。
我做错了什么?
您链接的存储库似乎只提供工具链,而不提供 header。
安装 libc++-dev 您从 Ubuntu 存储库安装了软件包,其中不包括实验目录中的 header 文件。
您可以检查 this 问题以自行构建 libc++ 并适当地设置工具链。
查看 clang-5.0 release notes it says that "C++ coroutines TS has landed", and suggests to check out this example 以开始使用。我显然可以 运行 在线示例,所以我决定在我的 Ubuntu Server 16.04 Xenial 机器上尝试。
我刚刚尝试了全新安装
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-5.0 main"
sudo apt-get update
sudo apt-get install -y clang-5.0 libc++-dev
然后直奔
clang++-5.0 -Wall -Wextra -std=gnu++2a "-fcoroutines-ts" "-stdlib=libc++" -o test.out test.cpp
(test.cpp
是 the aforementioned example 的复制粘贴)
然而,我只是得到
coroutines.cpp:2:10: fatal error: 'experimental/coroutine' file not found
#include <experimental/coroutine>
所以我可以想象我遗漏了一些东西,无论是安装还是编译标志。我试图在网上查找,但找不到任何有用的东西。
我做错了什么?
您链接的存储库似乎只提供工具链,而不提供 header。
安装 libc++-dev 您从 Ubuntu 存储库安装了软件包,其中不包括实验目录中的 header 文件。
您可以检查 this 问题以自行构建 libc++ 并适当地设置工具链。