Hi,

Note the error is not specific to gcc. Macports clang has the same problem.

 > clang++-mp-8.0 -O3 ./main.cpp 
In file included from ./main.cpp:1:
In file included from 
/opt/local/libexec/llvm-8.0/bin/../include/c++/v1/iostream:38:
In file included from /opt/local/libexec/llvm-8.0/bin/../include/c++/v1/ios:215:
In file included from 
/opt/local/libexec/llvm-8.0/bin/../include/c++/v1/iosfwd:96:
/opt/local/libexec/llvm-8.0/bin/../include/c++/v1/wchar.h:119:15: fatal error: 
'wchar.h' file not found
#include_next <wchar.h>
              ^~~~~~~~~
1 error generated.

The issue is both macports clang and gcc rely (by default) on /usr/include 
being present, and this is no longer present by default with Xcode 11, and even 
if you previously had it was likely wiped out with the last update.

Note, with 10.14 at least (*) you can add back /usr/include by following the 
instructions in 

https://apple.stackexchange.com/questions/337940/why-is-usr-include-missing-i-have-xcode-and-command-line-tools-installed-moja
 
<https://apple.stackexchange.com/questions/337940/why-is-usr-include-missing-i-have-xcode-and-command-line-tools-installed-moja>

or, as you say below, explicitly giving the include path in some way, such as 
the suggestion below.

cheers Chris

(*) The package to add back /usr/include currently does not exist in 10.15 
beta, so unless it reappears come final release this is going to be more of a 
problem thereā€¦.

> On 24 Sep 2019, at 7:09 am, Joshua Root <j...@macports.org> wrote:
> 
> On 2019-9-24 15:31 , Mihir Luthra wrote:
>> Hi,
>> 
>> After the xcode update, there have been many question on stackoverflow
>> regarding gcc and g++ linking fails. Any ideas on what can be done?
>> 
>> https://stackoverflow.com/questions/58072318/cannot-link-any-c-program-with-gcc-on-mac-mojave
>> 
>> https://stackoverflow.com/questions/58073301/linker-error-when-trying-to-use-lzma-in-boostiostreams-from-macports
>> 
>> https://stackoverflow.com/questions/58071057/macports-g-fails-to-find-headers-after-recent-xcode-update
>> 
>> Mihir
> 
> Does passing -isysroot`xcrun --show-sdk-path` to the compiler not work?
> 
> While that should make it find headers again, I don't know how many bugs
> it will uncover. I'm not sure how we would make this work out of the box
> for everyone, since AIUI, gcc needs to apply different fixups to the
> system headers depending on the SDK version and does so at build time.
> So Apple taking away not only the SDK corresponding to the current OS
> version but also /usr/include is quite problematic. We can ship a gcc
> supporting the 10.14 SDK or the 10.15 SDK, but not both.
> 
> Rebuilding gcc from source would also work.
> 
> - Josh

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to