Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Disclaimer - I am completely new to C++ and the way this language works regarding compiling / linking. Using MacOS Mojave.
For a school course we are obliged to use the g++ compiler to compile our c++ projects. G++ seems to be successfully installed; g++ -v results in the following output:
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin17.5.0/8.1.0/lto-wrapper
Target: x86_64-apple-darwin17.5.0
Configured with: ../gcc-8.1.0/configure --enable-languages=c++,fortran
Thread model: posix
gcc versie 8.1.0 (GCC)
I created my first "hello world" program:
#include <iostream>
using namespace std;
int main() {
cout << "Hello, World!" << endl;
return 0;
When I tried to compile this code (using 'g++ file.cpp), the following terminal output prompted:
In file included from /usr/local/include/c++/8.1.0/bits/postypes.h:40,
from /usr/local/include/c++/8.1.0/iosfwd:40,
from /usr/local/include/c++/8.1.0/ios:38,
from /usr/local/include/c++/8.1.0/ostream:38,
from /usr/local/include/c++/8.1.0/iostream:39,
from ex1.cpp:1:
/usr/local/include/c++/8.1.0/cwchar:44:10: fatale fout: wchar.h: No such file or directory
#include <wchar.h>
^~~~~~~~~
compilation ended.
The whcar.h file is indeed not present in the above folder. After some digging, I found the whcar file in the following folder: /Library/Developer/CommandLineTools/usr/include/c++/v1
Unfortunately I am a bit lost and don't really know what I am talking about, consindering everything is really new for me.
It is greatly appreciated if anyone can guide me in the right direction.
Kind regards,
Thijmen.
–
–
–
–
For me, reinstalling Xcode Command Line Tools and g++ solved the same issue:
xcode-select --install
brew reinstall gcc
The last line is assuming you have installed homebrew.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.