Opened 4 years ago

Last modified 4 years ago

#60449 closed defect

gcc10 missing header <wchar.h> — at Version 4

Reported by: haberg-1 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.

Change History (4)

comment:1 Changed 4 years ago by cjones051073 (Chris Jones)

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.

export SDKROOT=`xcrun --show-sdk-path`

then you should be fine.

 > cat test.cpp
#include <wchar.h>
#include <iostream>
int main() {
  wchar_t a = 99;
  std::cout << "Test " << a << std::endl;
  return 0;
}
 > g++-mp-10 ./test.cpp
 > ./a.out 
Test 99

Another option is to install the command line tools package.

Last edited 4 years ago by cjones051073 (Chris Jones) (previous) (diff)

comment:2 Changed 4 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 4 years ago by cjones051073 (Chris Jones)

Cc: cjones051073 added

comment:4 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

Description: modified (diff)
Note: See TracTickets for help on using tickets.