stdlib.h compilation error for macports gcc9.

Carlo Tambuatco oraclmaster at gmail.com
Sun Feb 7 21:24:55 UTC 2021


I don’t know if this is a result of updating to the latest macports gcc9, or the update of XCode, but 
all of a sudden when I try to build my C++ program which includes <cstdio> I get this strange 
chain reaction of errors.

In file included from /opt/local/include/gcc9/c++/ext/string_conversions.h:41,
                 from /opt/local/include/gcc9/c++/bits/basic_string.h:6493,
                 from /opt/local/include/gcc9/c++/string:55,
                 from /opt/local/include/gcc9/c++/bits/locale_classes.h:40,
                 from /opt/local/include/gcc9/c++/bits/ios_base.h:41,
                 from /opt/local/include/gcc9/c++/ios:42,
                 from /opt/local/include/gcc9/c++/ostream:38,
                 from /opt/local/include/gcc9/c++/iostream:39,
                 from ../../standard_includes.h:1,
                 from E2.5.2.cpp:1:
/opt/local/include/gcc9/c++/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
   75 | #include_next <stdlib.h>


From my makefile this seems to be the offending includes statement:

#include <iostream>
#include <cstdio>


I’ve googled and it seems that it can’t find stdlib.h, even though it is on my CPATH environment variable:

export CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include:/usr/local/include:/opt/local/include:/usr/local/dart-sdk/include:/Library/Frameworks/R.framework/Resources/include



More information about the macports-users mailing list