stdlib.h compilation error for macports gcc9.

Christopher Jones jonesc at hep.phy.cam.ac.uk
Sun Feb 7 22:39:53 UTC 2021


macOS 11 brought big changes to how Apple versions its SDKs. They now potentially change each minor update, and as such we had to figure out how to deal with this.

gcc is built against a specific SDK, and to handle this unpredictably it was recently changed to use the unversioned SDK, instead of a versioned one, where required.

https://github.com/macports/macports-ports/commit/e8866c5019d60832527850b4e50fdc1de8878716#diff-5aeb3e82f6999f57229a816d2877a6232489c3484ac3e6716cb7e62b5a82696f <https://github.com/macports/macports-ports/commit/e8866c5019d60832527850b4e50fdc1de8878716#diff-5aeb3e82f6999f57229a816d2877a6232489c3484ac3e6716cb7e62b5a82696f>

Are you on maOS 11 ?

please post the output you get from your failing build, showing the full command line you use, and the full output, and include the -v option to get additional diagnostic output.

Chris

> On 7 Feb 2021, at 10:24 pm, Carlo Tambuatco <oraclmaster at gmail.com> wrote:
> 
> Well what's odd is I'm only getting this error after upgrading to the latest macports gcc9. Indeed when I use the XCode provided clang version of gcc, it finds all the required libraries. My CPATH environment variable was sufficient to specify the locations of the libraries before the upgrade, so the question is, what changed post-upgrade?
> 
> On Sun, Feb 7, 2021, 5:03 PM Chris Jones <jonesc at hep.phy.cam.ac.uk <mailto:jonesc at hep.phy.cam.ac.uk>> wrote:
> 
> 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 <mailto: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
> > 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macports.org/pipermail/macports-users/attachments/20210207/538c55a7/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1930 bytes
Desc: not available
URL: <http://lists.macports.org/pipermail/macports-users/attachments/20210207/538c55a7/attachment.bin>


More information about the macports-users mailing list