Using Macports' gcc8 to build C programs and libraries

Ken Cunningham ken.cunningham.webuse at
Tue Apr 2 03:28:01 UTC 2019

> Adding
> "-I/Applications/"
> to CFLAGS appears to have fixed the problem (all of the libraries in
> question build).

When using clang on new versions of MacOS, the compiler driver looks to see if you have specified an -isysroot on the build command line.

If you have not specified one, it automatically will add -isysroot /Applications/ for you to the build line, so that the compiler finds an appropriate -isysroot (that previously would be in "/").

You can duplicate this behaviour on gcc by adding the -isysroot yourself to the gcc build lines. I haven't experimented enough to say if gcc finds it's own headers first and looks in the sysroot for any missing ones, or looks in the sysroot first. The gcc headers and the MacOS.sdk (clang) headers are certainly different enough to cause hiccups sometimes.

We can imagine why Apple went to this trouble -- security reasons, maintaining integrity and reducing pollution of the SDK, ability to move the SDK around to different versions more easily, etc, etc.


More information about the macports-users mailing list