每当我尝试在Mac上的Xcode上构建代码时,都会收到以下错误。
我当前的系统:
macOS:版本10.15.1(19B88)
Xcode:版本11.2.1(11B500)
我的错误:
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++
后,我得到在运行
g++ --version
之后,我得到了最佳答案
使用SDK 10.15,Xcode 11并启用C++ 17编译器可以解决此问题。
要启用C++ 17,请点击此链接:Enable C++17 on Xcode, macOS
在您的Xcode上,从常规设置中,选择 10.15 SDK作为部署目标,您可以使用。