[英]'wchar.h' file not found
我知道這個問題: macOS 'wchar.h' File Not Found但它對我沒有幫助。 我試過重新安裝 xcode,重新安裝命令行工具,重新啟動系統。 wchar.h 文件就位,但編譯器無法找到它。 我還能嘗試什么? 也許它與 sysroot 相關? 有什么辦法可以解決嗎?
macbooks-MacBook-Pro:Rack euphorbium$ sudo make
c++ -Iinclude -Idep/include -Idep/lib/libzip/include -DVERSION=dev -MMD -O3 -march=core2 -ffast-math -g -Wall -DARCH_MAC -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.7 -DAPPLE -stdlib=libc++ -std=c++11 -stdlib=libc++ -c -o build/src/app.cpp.o src/app.cpp
clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk' [-Wmissing-sysroot]
In file included from src/app.cpp:1:
In file included from include/app.hpp:2:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/vector:265:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/iosfwd:90:
/Library/Developer/CommandLineTools/usr/include/c++/v1/wchar.h:119:15: fatal error:
'wchar.h' file not found
#include_next <wchar.h>
^~~~~~~~~
1 error generated.
make: *** [build/src/app.cpp.o] Error 1
由於 wchar.h 存在於 xcode 應用程序和/Library/Developer/CommandLineTools
我認為它在一些完全不相關的文件夾中查找它。
升級到 macOS High Sierra 后我遇到了同樣的問題。 在此錯誤停止工作之前正在編譯的項目。 就我而言,項目文件是由 CMake 應用程序生成的。 解決方案是再次運行 CMake、“刪除緩存”和“配置”項目。 這更正了 make 文件中的 sysroot 目錄引用以指向新的 SDK,並解決了錯誤。
我有同樣的問題。 我能夠通過使用符號鏈接來修復它。 這是我做的:
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
sudo ln -s MacOSX.sdk MacOSX10.07.sdk
然后輸入你的root密碼。
注意:您必須使用所需的 sdk 調整最后一行。
對於在 MacOSX Mojave 上為此苦苦掙扎的任何人,這個答案都能解決。 簡而言之:
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
這將彈出安裝 Xcode 工具的提示。sudo xcode-select -s /Library/Developer/CommandLineTools
我的系統是 macOS Mojave,我通過運行以下命令行解決了這個問題:
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
它是由在 makefile 中設置的不正確的 sysroot(為較舊的 mac os 版本設置)引起的。
設置環境變量
SDKROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk"
並重新打開終端。 這解決了未找到標頭的問題。
要查看編譯器在哪里找到頭文件,請使用-v
運行
clang -v test.c
就我而言,這個問題是由於 MacOS 更改了標頭的路徑造成的。
檢查此說明: MacOS 發行說明。 所以解決方案是讓編譯器可以找到那些頭文件。 我的 macOS 版本是 Catalina 10.15,XCode 版本 12.4。 對於此版本,似乎不再提供/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
,因此上述 sulotions 對我不起作用。
這個方法拯救了我的夜晚: Fixing C++ compiler bugs for the MacOS Catalina upgrade 。 請注意,如果您按照其步驟操作並出現未找到某些全局符號的錯誤,請不要像它所說的那樣修改 LIBRARY_PATH。
如果您使用的是 CLion,請按照以下步驟操作:
我花了 3 個小時才找到這個解決方案。
僅供參考,這個項目在 Bug Sur 11.3 上運行良好,但在我升級到 Big Sur 11.4 后無法構建
我做了一些愚蠢的事情,但它確實解決了問題……但不確定它是否適用於您的計算機。
這是我所做的:我最初在 Mojave 上的 MacBook 上使用 Homebrew 安裝了 c++...所以我不得不使用/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
的安裝程序手動安裝 Xcode CommandLineTools。 然后我將“c++”文件夾內容從文件夾/Library/Developer/CommandLineTools/usr/include/c++/v1
復制到我想要丟失文件所在的文件夾,位於/usr/local/Cellar/gcc/8.2.0/include/c++/8.2.0
,同時替換同名文件。
這個技巧奏效了,因為現在丟失的文件“wchar.h”就在它應該在的地方......但是,我擔心你的設置可能不一樣。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.