'wchar.h' file not found - c++

I know about this question: macOS 'wchar.h' File Not Found
but it did not help me. I've tried reinstalling xcode, reinstalling command line tools, restarting the system. wchar.h file is in place, but the compiler does not manage to find it. What else could I try? Maybe it is sysroot related? Any way to fix that?
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
since wchar.h exists both in the xcode app, and in the /Library/Developer/CommandLineTools I think that it looks for it in some completely unrelated folder.

I had the same problem after upgrading to macOS High Sierra. A project which was compiling before stopped working with this error. In my case, the project files had been generated by the CMake application. The solution was to run CMake, 'Delete Cache', and 'Configure' the project again. This corrected the sysroot directory reference in the make files to point to the new SDK and the error was resolved.

I've got the same problem. I was able to fix it by using a symbolic link.
This is what I made :
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
sudo ln -s MacOSX.sdk MacOSX10.07.sdk
Then enter your root password.
NB: you have to adapt the last line with required sdk.

For any one struggling with this on MacOSX Mojave this answer solves it. In short:
Go to the terminal and run open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg This will bring up the prompt to install Xcode tools.
After that's done got to the terminal and run sudo xcode-select -s /Library/Developer/CommandLineTools

My system is macOS Mojave, and I've fixed this problem by running this command line:
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

It was caused by incorrect sysroot, (set for an older mac os version) set in makefiles.

If you are using CLion, follow these steps :
Click on CMake at the bottom center of your IDE
Click on the Settings Gear Icon at the left
Click on Reset Cache and Reload Project
Took me 3 hours to find this solution.
FYI this project was running fine on Bug Sur 11.3 but failed to build after I upgraded to Big Sur 11.4

Set an environment variable
SDKROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk"
and reopen Terminal. This solves the header not found issue.
To see where the compiler finds headers, run with -v
clang -v test.c

For my case, this problem result from that MacOS changes the headers's path.
Check this note: MacOS release note.
So the solution is to make the compiler can find those headers.
My macOS version is Catalina 10.15, and XCode Version 12.4. For this version, it seems that /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg is not provided anymore and thus the sulotions above do not work for me.
This method saved my night: Fixing C++ compilation bugs for the MacOS Catalina upgrade. Note that if you follow its steps and errors that some global symbols are not found arise, do not modify the LIBRARY_PATH as it says.

I did something dumb but it did fix the problem... Not sure if it will work for your computer though.
Here is what I did:
I originally installed c++ using Homebrew on my MacBook on Mojave... so I had to manually install the Xcode CommandLineTools using the installer found at /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg . Then I copied the "c++" folder contents from to folder /Library/Developer/CommandLineTools/usr/include/c++/v1 to the folder where I want the missing file to be, at /usr/local/Cellar/gcc/8.2.0/include/c++/8.2.0 , while replacing files with the same names.
The trick worked, since now the missing file "wchar.h" is right where it should be... Your settings is probably not the same, however, I am afraid.

Related

_ctermid.h: No such file or directory error on mac without Xcode

I was trying to compile my code using gcc 10.2.8 and I got this error:
scons: *** [S.os] Error 1
In file included from /usr/local/Cellar/gcc/10.2.0_2/include/c++/10.2.0/cstdio:42,
from Public_Library/C.h:10,
from Public_Library/D.h:11,
from Public_Library/RS.h:10,
from Projects/S/main.cpp:1:
/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include-fixed/stdio.h:219:10: fatal error: _ctermid.h: No such file or directory
I found a few questions like this but the problem is I don't have Xcode on my mac and I have already updated my CommandLine tools several times and it did not work.
I'm using OSX 10.14.6 by the way.
I'm just gonna add this in case it might help others. I updated my OSX to big sure and installed Xcode but that did not help. What solved the problem for me was getting an unshallow version of brew with this command:
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
and then updating and upgrading my brew.
brew update
brew upgrade

Homebrew clang can't find C standard library headers [duplicate]

This question already has answers here:
'wchar.h' file not found
(9 answers)
Closed 2 years ago.
Unsurprisingly the new update of OSX Mojave broke my llvm installation in Homebrew, these are the steps I tried:
xcode-select --install # Complained, so I installed commandLineTools from here https://developer.apple.com/download/more/
xcode-select -p /Library/Developer/CommandLineTools
xcode-select --install # Now says installed
sudo xcodebuild -license # Fails, as it says I only have CommandLineTools installed in /Library/Developer/CommandLineTools not xcode
# Try something else (all versions)
brew uninstall --force llvm
brew install llvm # yay v7 how exciting
# Only it still don't work
clang++ -std=c++17 foo.cpp -o f
In file included from foo.cpp:1:
In file included from /usr/local/Cellar/llvm/7.0.0/include/c++/v1/iostream:38:
In file included from /usr/local/Cellar/llvm/7.0.0/include/c++/v1/ios:215:
In file included from /usr/local/Cellar/llvm/7.0.0/include/c++/v1/iosfwd:90:
/usr/local/Cellar/llvm/7.0.0/include/c++/v1/wchar.h:119:15: fatal error: 'wchar.h' file not found
#include_next <wchar.h>
^~~~~~~~~
1 error generated.
Any ideas? The first half of the things I tried I found online but mostly for older updates of MacOS, maybe Mojave broke things in a new and unpredictable way.
Here's how I solved it (very dirty but has worked for a long time):
Disabled SIP on my Mac
Symlinked /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include to /usr/include as is expected in POSIX environments.
Re-enabled SIP.
Now I got to make a note to re-do this everytime a new OSX update comes out. This has not broken anything wrt Xcode, clang (from brew) etc so I'll keep it. Be advised though, this might break your stuff.
This is a well known issue of the latest macos. Try to set this environment variable, it must fix this issue.
export LIBCLANG_SYSTEM_INCLUDE_DIR="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
I did something dumb but it did fix the problem... Not sure if it will work for your computer though.
Here is what I did:
I originally installed c++ using Homebrew on my MacBook on Mojave... so I had to manually install the Xcode CommandLineTools using the installer found at /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg . Then I copied the "c++" folder contents from to folder /Library/Developer/CommandLineTools/usr/include/c++/v1 to the folder where I want the missing file to be, at /usr/local/Cellar/gcc/8.2.0/include/c++/8.2.0 , while replacing files with the same names.
The trick worked, since now the missing file "wchar.h" is right where it should be... I could have simlinked, in hindsight. Cheers!

CMake error no CMAKE_C_COMPILER could be found using Xcode and GLFW

I'm trying to follow this tutorial to get started with OpenGL: http://www.learnopengl.com/#!Getting-started/Creating-a-window and it requires downloading glfw and CMake.
I have set the downloaded glfw folder as the source code folder and I have created inside that folder another one called "build" which I then set as the build one for the binaries, as the tutorial asks.
I click on "Configure" and I select XCode as the Generator, since I'm on a Mac.
The problem is that when I try to configure the project CMake gives me this error:
The C compiler identification is unknown
CMake Error at CMakeLists.txt:3 (project):
No CMAKE_C_COMPILER could be found.
Configuring incomplete, errors occurred!
See also "/Users/standard/Desktop/glfw-3.2.1/build/CMakeFiles/CMakeOutput.log".
See also "/Users/standard/Desktop/glfw-3.2.1/build/CMakeFiles/CMakeError.log".
I've already read this question, but as far as I can understand, it doesn't have what I need:
CMake error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found
If you have installed Xcode or Command Line Tools for Xcode, try this:
sudo xcode-select --reset
This happened to me with Xcode10 / Cmake 3.12 after installing Homebrew. Running sudo xcode-select --reset fixed it for me.
Did you install Xcode and Xcode Commandline Tools?
xcode-select --install
If you have Xcode Commandline Tools installed, you should no longer be receiving the xcrun is missing error.
How did you install Cmake? Once you have ensured that Xcode Commandline Tools is installed, please completely remove Cmake from your system and reinstall it. You have a screwed up configuration. There are ways to debug and fix it without a clean install, but since you are new to this, it will be the easiest and lest frustrating way.
Failing that if you do have Xcode Commandline Tools installed, hstdt suggested trying this:
sudo xcode-select --reset
This error means CMake cannot find your standard C/C++ Compiler, looks like you'll need to export the environment variables yourself. you can find the path of your C/C++ compiler with:
xcrun -find c++
xcrun -find cc
Then afterwards when you have the paths, create two variables inside the gui. If you are running it from the cline, it would be something like
cmake -D CMAKE_C_COMPILER="/path/to/your/c/compiler/executable" -D CMAKE_CXX_COMPILER="/path/to/your/cpp/compiler/executable" ...
On a fresh Xcode install the command line tools complain about agreeing to the EULA which build tools don't like. Which you can do with:
sudo xcodebuild -license
If you are on a Mac computer and have Homebrew, you can simply upgrade cmake, forcing the compiler to be reconfigured:
brew upgrade cmake
In my case, I needed to install CMake from CMake official site, download the .dmg, install it and then add the CMake folder the system's PATH.
Before the installation, the output of which cmake is /usr/local/bin/cmake.
After the installation it should be something like /Applications/CMake.app/Contents/bin/cmake.
This has solved the issue for me.
I get exactly this error if ccache is enabled on my machine. Disabling ccache fixed the problem for me.
To check if ccache is enabled, print the systems variables CC or CXX:
echo $CC
echo $CXX
This prints something like the following: ccache clang -Qunused-arguments -fcolor-diagnostics. (CC or CXX are typically overridden by the .bashrc or .zshrc file.)
To disable ccache, use the following:
CC=clang
CXX=clang++
Then rebuild the cmake project:
cmake -G Xcode <path/to/CMakeLists.txt>
Apparently, it is possible to use CMake's Xcode generator also in combination with ccache, as is described here. But I never tried it out myself.
I got this error when I had an invalid value set for CMAKE_OSX_SYSROOT. I was trying to give it the name of the SDK e.g. "macOS 10.13". Setting it to the full path of the SDK resolved the issue.
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk
Compiler detection appears to be broken with Xcode 10 and older versions of CMake. I know that it broke for me with CMake 2.2 and upgrading to the latest (2.13) solved it for me. It was working fine with Xcode 9 and it broke with the upgrade. I tried the other solutions (all good depending on your situation) but upgrading CMake fixed the issue.
If you are on CLion and facing this issue try changing the C and C++ compiler location inside Toolchains settings to the latest one. the default GCC installation directory is /usr/local/Cellar/gcc/...
after I upgrade Xcode to new verison, I met this error, then I upgrade my cmake version, problem solved.
For anyone coming to this question nowadays from google, my problem was fixed via
xcodebuild -runFirstLaunch
I found this by inspecting CMakeFiles/CMakeError.log

Xcode gcc: dependency_info.dat No such file or directory

Hi anyone can help with dependency_info.dat No such file or directory? I'm using Xcode 7 with gcc 4.8
-dependency_info /path/my_project/build/my_project/Debug/my_project.build/Objects-normal/x86_64/my_project_dependency_info.dat
g++-4.8: error:/path/my_project/build/my_project/Debug/my_project.build/Objects-normal/x86_64/my_project_dependency_info.dat: No such file or directory
Command /usr/local/bin/g++-4.8 failed with exit code 1
what does -dependency_info flag do? How can I remove this flag?
The error went away after I deleted the path specified in Build Settings "Path to Linker Dependency Info File" for the project and the targets. So far the app is compiling and running fine without a specified path.
I had a very similar error with Xcode 7.2, OpenCV 3 and El Capitan.
In my case (and probably in yours as well), it's a linker error disguised as something else.
My project builds fine via terminal (because it already has a makefile that uses gcc), but no chance with XCode even after I configure everything in Build Settings pane according to the makefile.
This answer saved me. My OpenCV was installed using macports (it might have been precompiled binaries, or compiled on my machine, can't remember). It turns out that it's compiled with libc++ and not libstdc++.
Changing the C++ Standard Library setting accordingly in Build Settings did the trick for me.
For me it was trying to use a "/" in the app's display name that caused the build error

configure MinGW with Eclipse CDT

I have searched a lot about this and read most of the available answers for similar problem but I still couldn't solve it. Therefore, any help will be helpful.
I am using Eclipse Mars(Latest version after Luna) on Windows 7
MinGW is installed in "C:\Program Files (x86)\CodeBlocks\MinGW\bin".
Environment variable "Path" contains "C:\Program Files (x86)\CodeBlocks\MinGW\bin;..."
Preferences -> C/C++ -> Build -> Settings -> Discovery->CDT GCC Built-in Compiler Settings : command to get compiler specs
${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"
manually doing gcc -E -P -v -dD in cmd from any directory gives
.
.
Target: mingw32
.
.
Errors:
Program g++/gcc not found in PATH
I make a C++ project, add a file with hello world program in it.
I get errors "unresolved inclusion " and 'printf' could not be resolved.
comment if any other details required
It sounds like you're doing everything correctly.
TWO SUGGESTIONS:
Take a look at this link, and see if you missed anything regarding the MinGW/GCC install:
https://www3.ntu.edu.sg/home/ehchua/programming/howto/EclipseCpp_HowTo.html
Otherwise, consider deleting (or simply renaming) your current Eclipse and installing the CDT (Eclipse for C/C++ Developers) version instead:
http://www.eclipse.org/downloads/
For whatever it's worth, here are a couple of screenshots from my property settings (I'm able to create and successfully build a new C project):
I think your problem is simply because of MinGW path include white spaces in it. just reinstalling MinGW on Root directory "c:\MinGW"will solve your problem.
install MinGW with basic setup packages select "mingw-developer-toolkit, mingw32-base, mingw32-gcc-g++, msys-base". complete installation.
restart your pc. then check your eclipse settings.
I hope your problem is already solved.
I also faced such problems,you need to set environment variable, In path add your MinGW location, if you haven't downloaded MinGW go here for downloading MinGW:
http://sourceforge.net/projects/mingw/files/latest/download?source=files
Simple solution is:
For more and detailed information to fix your problem, it worked for me!
Visit here:
http://www.multigesture.net/articles/how-to-install-mingw-msys-and-eclipse-on-windows/