#60449 closed defect (invalid)
gcc10 missing header <wchar.h>
Reported by: | haberg-1 (Hans Åberg) | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.6.2 |
Keywords: | catalina | Cc: | cjones051073 (Chris Jones) |
Port: | gcc10 |
Description (last modified by ryandesign (Ryan Carsten Schmidt))
When installing gcc10 and compiling externally with /opt/local/bin/g++-mp-10 the error below appears, possibly because system headers that GCC relies on, have on MacOS 10.5 been moved away from /usr/include/.
In file included from /opt/local/include/gcc10/c++/bits/postypes.h:40, from /opt/local/include/gcc10/c++/iosfwd:40, from /opt/local/include/gcc10/c++/ios:38, from /opt/local/include/gcc10/c++/ostream:38, from /opt/local/include/gcc10/c++/iostream:39, from c++version.cc:2: /opt/local/include/gcc10/c++/cwchar:44:10: fatal error: wchar.h: No such file or directory 44 | #include <wchar.h> | ^~~~~~~~~ compilation terminated.
Attachments (2)
Change History (15)
comment:1 Changed 5 years ago by cjones051073 (Chris Jones)
comment:2 Changed 5 years ago by cjones051073 (Chris Jones)
b.t.w. another option is to run your compilation through xcrun. e.g.
> xcrun g++-mp-10 ./test.cpp
comment:3 Changed 5 years ago by cjones051073 (Chris Jones)
Cc: | cjones051073 added |
---|
comment:4 Changed 5 years ago by ryandesign (Ryan Carsten Schmidt)
Description: | modified (diff) |
---|
comment:5 Changed 5 years ago by haberg-1 (Hans Åberg)
Yes, I am aware of those variations, but gcc9 and clang-10 work without that, so you might check what they do. And the command line tools package does not help here, as /usr/include/ does not exist.
Changed 5 years ago by cjones051073 (Chris Jones)
Changed 5 years ago by cjones051073 (Chris Jones)
comment:6 Changed 5 years ago by cjones051073 (Chris Jones)
The command line tools package does not install to /usr/include. Instead it installs SDKs to /Library/Developer/CommandLineTools
I see no difference in the behaviour or content of gcc10, compared to gcc9.
Oberon ~/Downloads > port contents gcc9 | grep wchar /opt/local/include/gcc9/c++/cwchar /opt/local/include/gcc9/c++/tr1/cwchar /opt/local/include/gcc9/c++/tr1/wchar.h Oberon ~/Downloads > port contents gcc10 | grep wchar /opt/local/include/gcc10/c++/cwchar /opt/local/include/gcc10/c++/tr1/cwchar /opt/local/include/gcc10/c++/tr1/wchar.h Oberon ~/Downloads > port contents libgcc10 | grep wchar /opt/local/include/gcc/c++/cwchar /opt/local/include/gcc/c++/tr1/cwchar /opt/local/include/gcc/c++/tr1/wchar.h
Please test build the example application I posted above, using the -H option, and compare to the logs I attached above.
comment:7 Changed 5 years ago by cjones051073 (Chris Jones)
Note, the logs I attached above or *without* setting SDKROOT
, or using xcrun
. Its what I get out-the-box just using
g++-mp-10 -H test.cpp
etc.
comment:8 Changed 5 years ago by haberg-1 (Hans Åberg)
It gives compilation error:
% /opt/local/bin/g++-mp-10 test.cpp -o test test.cpp:1:10: fatal error: wchar.h: No such file or directory
1 | #include <wchar.h>
|
compilation terminated.
comment:9 Changed 5 years ago by haberg-1 (Hans Åberg)
I also get the same error with gcc9, as below. However, it works with clang-10: the issue arose with the binary at https://llvm.org, fixable by the same workaround, but somehow, you have fixed it.
--
% /opt/local/bin/g++-mp-9 test.cpp -o test
test.cpp:1:10: fatal error: wchar.h: No such file or directory
1 | #include <wchar.h>
|
compilation terminated.
--
% /opt/local/bin/clang++-mp-10 test.cpp -o test
<no diagnostic>
--
comment:10 Changed 5 years ago by cjones051073 (Chris Jones)
Run build with the -v option. That will tell you agmonst other things the search paths the compiler is using to find headers.
> g++-mp-10 -v test.cpp <snip> #include <...> search starts here: /opt/local/include/gcc10/c++/ /opt/local/include/gcc10/c++//x86_64-apple-darwin19 /opt/local/include/gcc10/c++//backward /opt/local/lib/gcc10/gcc/x86_64-apple-darwin19/10.1.0/include /opt/local/lib/gcc10/gcc/x86_64-apple-darwin19/10.1.0/include-fixed /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks End of search list. <snip>
Do you have the CLT installed ? i.e. what is in
> ls -l /Library/Developer/CommandLineTools/SDKs/ total 0 lrwxr-xr-x 1 root wheel 15 16 Apr 12:53 MacOSX.sdk -> MacOSX10.15.sdk drwxr-xr-x 7 root wheel 224 16 Apr 12:53 MacOSX10.14.sdk drwxr-xr-x 8 root wheel 256 16 Apr 12:53 MacOSX10.15.sdk
Bottom line is, with the removal of /usr/include, you have to do *something* to instruct the compiler where to find the SDK to use.
- define SDKROOT
- use xcrun
- pass the
-sysroot /path/to/SDK
compiler flag - install the CLT package
comment:11 Changed 5 years ago by haberg-1 (Hans Åberg)
It works after running 'xcode-select —install', both gcc9 and gcc10. I had it installed before, but perhaps it was lost in some update; a working compiler in /usr/bin/clang++, though. Before, I had bin/ in /Library/Developer/CommandLineTools/usr/, but not include/, which is now present. Also, gcc9 may have worked before, but not after removing and reinstalling. But clang-10 worked, so it may be different in this respect.
comment:12 Changed 5 years ago by cjones051073 (Chris Jones)
Resolution: | → invalid |
---|---|
Status: | new → closed |
Sounds like you perhaps ran into something like
https://trac.macports.org/wiki/ProblemHotlist#reinstall-clt
For that port should have given you some warnings and directed you to the above site.
Anyway, glad you have sorted your problem out.
comment:13 Changed 5 years ago by haberg-1 (Hans Åberg)
Some installed stuff seemed to missing such as /Library/Developer/CommandLineTools/usr/include/, and I did not get any complaints about that from MacPorts. It would be great if one can somehow can get a reminder to run 'xcode-select —install'.
Yes, this is likely due to the removal of /usr/include
Like clang, gcc now respects your SDKROOT setting, so this is the recommendation now. i.e.
then you should be fine.
Another option is to install the command line tools package.