Xcode OSX上的C ++构建失败,出现多个错误文件IO ...不可用:在macOS 10.15中引入 [英] C++ Build Failed on Xcode OSX with multiple errors File IO ... is unavailable: introduced in macOS 10.15
问题描述
每当我尝试在Mac上的Xcode上构建代码时,都会收到以下错误消息.
I am getting the following error whenever I try to build my code on Xcode on my Mac.
我当前的系统:
macOS:版本10.15.1(19B88)
Xcode:版本11.2.1(11B500)
My current system:
macOS: version 10.15.1 (19B88)
Xcode: Version 11.2.1 (11B500)
我的错误:
'path'不可用:在macOS 10.15中引入
'current_path'不可用:macOS 10.15中引入的
'operator/'不可用:在macOS 10.15中引入
'路径'不可用:macOS 10.15中引入的
'path'不可用:在macOS 10.15中引入
'path' is unavailable: introduced in macOS 10.15
'current_path' is unavailable: introduced in macOS 10.15
'operator/' is unavailable: introduced in macOS 10.15
'path' is unavailable: introduced in macOS 10.15
'path' is unavailable: introduced in 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++
后,我得到
After running g++
on terminal I get
c声:错误:没有输入文件
clang: error: no input files
运行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 Apple clang版本11.0.0(clang-1100.0.33.12) 目标:x86_64-apple-darwin19.0.0 螺纹型号:posix InstalledDir:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Configured with: --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 Apple clang version 11.0.0 (clang-1100.0.33.12) Target: x86_64-apple-darwin19.0.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
推荐答案
使用SDK 10.15,Xcode 11并启用C ++ 17编译器可以解决此问题.
Using SDK 10.15, Xcode 11 and and enabling C++17 compiler solved this issue.
要启用C ++ 17,请点击以下链接:在以下位置启用C ++ 17 Xcode,macOS
To enable C++17, followi this link: Enable C++17 on Xcode, macOS
在您的Xcode上,从常规"设置中选择 10.15 SDK作为部署目标,您就可以开始使用了.
On your Xcode, from General setting, select 10.15 SDK as Deployment Target and you are good to go for .
这篇关于Xcode OSX上的C ++构建失败,出现多个错误文件IO ...不可用:在macOS 10.15中引入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!