Using Macports' gcc8 to build C programs and libraries

Sean Lake odysseus9672 at gmail.com
Mon Apr 1 10:17:48 UTC 2019


As far as I know I have command line tools installed - I'm not even
sure how I could get MacPorts installed without them. Adding
"-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
to CFLAGS appears to have fixed the problem (all of the libraries in
question build). As for using gcc vs cc, I need to support this cross
platform on Linux and MacOS, so I would like to stick to a single
toolchain for both.

On Mon, Apr 1, 2019 at 5:27 PM Chris Jones <jonesc at hep.phy.cam.ac.uk> wrote:
>
> Hi,
>
> My macOD 10.13 box I have access to right now has
>
> /usr/include/sys/cdefs.h
>
> which should be found by default.
>
> I suspect this is a case of the OP's macOS10.14 does not have the
> command line tools package installed (as this is depreciated in 10.14)
> and thus does not have this header installed.
>
> If so, then I go back to my last post. The best fix here is to use clang
> instead of gcc.
>
> cheers Chris
>
>
> On 01/04/2019 10:18 am, Andrew Udvare wrote:
> >
> >
> >> On 2019-04-01, at 05:10, Sean Lake <odysseus9672 at gmail.com> wrote:
> >>
> >> In file included from MWReddening.c:1:
> >> /opt/local/lib/gcc8/gcc/x86_64-apple-darwin18/8.3.0/include-fixed/math.h:45:10:fatal
> >> error: sys/cdefs.h: No such file or directory
> >> #include <sys/cdefs.h>
> >>           ^~~~~~~~~~~~~
> >
> > You should have this file at:
> >
> > /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h
> >
> > Assuming GCC 8 can use Apple's headers, add:
> >
> > -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
> >
> >>
> >> Looking for similar errors on the web, I get pages like this
> >>
> >> https://stackoverflow.com/questions/31045721/c-compiler-error-cdefs-h-not-found
> >>
> >> that recommend installing a libc package. Will a similar solution work
> >> in Macports? If so, which package(s)? If not, will modifying my CFLAGS
> >> and LDFLAGS suffice? Currently, I have included "-I/opt/local/include"
> >> in CFLAGS and "-L/opt/local/lib" in LDFLAGS, but that's obviously not
> >> enough (or wrong).
> >
> >
> > There are some (dated) libc* packages. Run `port search 'Library for cross-platform C'`.
> >


More information about the macports-users mailing list