![](/img/trans.png)
[英]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.