【发布时间】:2020-03-15 12:04:31
【问题描述】:
每当我尝试在 Mac 上的 Xcode 上构建代码时,都会收到以下错误。
我当前的系统:
macOS:版本 10.15.1 (19B88)
Xcode:版本 11.2.1 (11B500)
我的错误:
'path' 不可用:在 macOS 10.15 中引入
'current_path' 不可用:在 macOS 10.15 中引入
'operator/' 不可用:在 macOS 10.15 中引入
“路径”不可用:在 macOS 10.15 中引入
'path' 不可用:在 macOS 10.15 中引入
main.cpp
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <filesystem>
using namespace std;
int main(int argc, char* argv[])
{
cout << "being exectued from:" << endl;
cout << argv[0] << endl;
std::__fs::filesystem::path cwd = std::__fs::filesystem::current_path() / "filename.txt"; // C++17
cout << "but the input.txt and output.txt files should be be in the following directory:" << endl;
cout << cwd.string() << endl << endl;
在终端上运行g++ 后,我得到了
clang:错误:没有输入文件
在运行g++ --version 之后,我得到了
配置为:--prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer /SDKs/MacOSX.sdk/usr/include/c++/4.2.1 苹果 clang 版本 11.0.0 (clang-1100.0.33.12) 目标:x86_64-apple-darwin19.0.0 线程模型:posix 安装目录:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
【问题讨论】:
-
请将错误发布为文本,而不是图像。不是每个人都能看到图片。
-
好的,改变 rn
-
你为什么用
std::__fs::filesystem而不是std::filesystem? -
你的项目必须使用10.15 SDK;在您的项目设置中更改它。这与 您 正在运行的操作系统版本无关;这是关于你的目标。
-
所以基本上我需要使用 10.15 SDK,无论我的操作系统运行什么版本。非常感谢@BradAllred 花时间帮助这个便便灵魂。现在一切都很好。再次感谢你。