[英]macOS 10.15 Catalina gdb problem for C++ Debugging in Eclipse
[英]C++ Build Failed on Xcode OSX with multiple errors File IO … is unavailable: introduced in macOS 10.15
每当我尝试在 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 中引入
'path' 不可用:在 macOS 10.15 中引入
'path' 不可用:在 macOS 10.15 中引入
主文件
#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 Apple clang 版本 11.0.0 (clang-1100.0.33.12) 目标:x86_64-apple-darwin19.0.0 线程 Z20F35E630DAF44DBFA4C3F68F5399D8C3Xcode.Installed/DAF44DBFA4C3F68F5399D8CContent/开发者/工具链/XcodeDefault.xctoolchain/usr/bin
使用 SDK 10.15、Xcode 11 并启用 C++17 编译器解决了这个问题。
要启用 C++17,请点击此链接: 在 Xcode 上启用 C++17,macOS
On your Xcode, from General setting, select 10.15 SDK as Deployment Target and you are good to go for.
添加
CONFIG += c++17
和
macx: {
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.15
}
到 your.pro 文件。 那应该将-std=gnu++1z -mmacosx-version-min=10.15
标志设置为编译器。 我还为 C++ 和 C 使用了 Apple Clang 编译器(可以在Preferences -> Kits中设置)。 不确定它是否很关键,但 GCC 肯定没有工作。
需要考虑的可能解决方案
您可能想 查看 libc++ 上的 llvm 文档。 如果您使用的是开箱即用的 xcode 11.2,那么您可能拥有 llvm 8.0。
使用 <文件系统>
在 LLVM 9.0 之前,libc++ 在单独的 static 库中提供文件系统库的实现。 <filesystem> 和 <experimental/filesystem> 的用户需要链接 -lc++fs。 在 libc++ 7.0 之前,<experimental/filesystem> 的用户需要链接 libc++experimental。
从 LLVM 9.0 开始,主库中提供了对 <filesystem> 的支持,使用 <filesystem> 不需要任何特殊要求。
所以你可能需要提到的包含和链接标志。
由于文档也没有提及,您还可以更新到较新的版本,然后尝试配置 Xcode 以使用更新的版本。
我现在没有 Mac 设置,所以我无法通过所有这些来确认。 但希望你能得到一些能让你前进的想法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.