C++ Build Failed on X-Code OSX with multiple errors File IO … is unavailable: introduced in macOS 10.15

两盒软妹~` 提交于 2019-12-24 21:54:53

问题


I am getting the following error whenever I try to build my code on X-Code on my Mac.

My current system:
macOS: version 10.15.1 (19B88) xcode: Version 11.2.1 (11B500)

my error:

'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;

I appriciate your help. I am new on macOS and still sorting things out.

After running g++ on terminal I get

clang: error: no input files

And after running g++ --version I get

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


回答1:


Using SDK 10.15, Xcode 11 and and enabling C++17 compiler solved this issue.

To enable C++17, followi this link: Enable C++17 on Xcode, macOS

On your Xcode, from General setting, select 10.15 SDK as Deployment Target and you are good to go for .



来源:https://stackoverflow.com/questions/58943032/c-build-failed-on-x-code-osx-with-multiple-errors-file-io-is-unavailab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!