stdlib.h compilation error for macports gcc9.

Chris Jones jonesc at hep.phy.cam.ac.uk
Sun Feb 7 22:03:15 UTC 2021


It sounds like your builds are not correctly specifying the SDK gcc is to use. There are a number of ways you can do this, either by pass it via a compiler flag, by running the complication through xcrun, or by setting the SDKROOT variables to the required path.

Cheers Chris

> On 7 Feb 2021, at 9:25 pm, Carlo Tambuatco <oraclmaster at gmail.com> wrote:
> 
> 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