Search code examples
xcodemacosperlcpancc

How to install perl modules on macos when cc can't handle stdlib.h


So in trying to install various Perl modules, including e.g. Module::Build, I get errors that stem from stdlib.h, like:

In file included from lib/Simple.xs:2:
In file included from /usr/local/Cellar/perl/5.28.2/lib/perl5/5.28.2/darwin-thread-multi-2level/CORE/perl.h:819:
/usr/include/stdlib.h:147:38: error: expected ')'
           size_t __width, int (* _Nonnull __compar)(const void *, const void *));
                                           ^
/usr/include/stdlib.h:147:26: note: to match this '('
            size_t __width, int (* _Nonnull __compar)(const void *, const void *));
                                ^

(There are many more errors, but that appears to be the first and seems like a representative and hopefully illustrative sample.)

I believe these errors are because my installation of cc and the included library don't match, but I'm not a c programmer and have no idea how to debug this. Also, the point here is to install perl modules, not learn C, so I am hopeful that some solution exists that does not involve debugging C.

Perl: 5.28.2
macOS: 10.13.6
cc -v: Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
  Target: x86_64-apple-darwin17.7.0
  Thread model: posix

Solution

  • Although Apple's App Store did not list XCode in the list of updates I needed, I tried installing the most recent version -- well, the most recent version it would allow for my OS -- and when I had finished, I had a new version of cc that worked.