How To Install/Update CPAN on MacOS Mojave with fatal error: ‘EXTERN.h’ file not found
erics, June 12th, 2019
The Problem Tried to install the latest version of cpan and got stuck. Tracked it down to the dependency module Mac::SystemDirectory which was failing to build:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
cpan[1]> install Mac::SystemDirectory Reading '/var/root/.cpan/Metadata' Database was generated on Sun, 09 Jun 2019 07:17:02 GMT Running install for module 'Mac::SystemDirectory' Running make for E/ET/ETHER/Mac-SystemDirectory-0.10.tar.gz Checksum for /var/root/.cpan/sources/authors/id/E/ET/ETHER/Mac-SystemDirectory-0.10.tar.gz ok Scanning cache /var/root/.cpan/build for sizes ............................................................................DONE CPAN.pm: Building E/ET/ETHER/Mac-SystemDirectory-0.10.tar.gz HASCOMPILEREZFt/TESTUSSI.c:2:10: fatal error: 'EXTERN.h' file not found #include "EXTERN.h" ^~~~~~~~~~ 1 error generated. Couldn't execute cc -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -fstack-protector -Os "-I/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE" -c HASCOMPILEREZFt/TESTUSSI.c -o HASCOMPILEREZFt/TESTUSSI.o: Inappropriate ioctl for device at Makefile.PL line 14. Requires a compiler Warning: No success on command[/usr/bin/perl Makefile.PL INC=-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE] ETHER/Mac-SystemDirectory-0.10.tar.gz /usr/bin/perl Makefile.PL INC=-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -- NOT OK Running make test Make had some problems, won't test Running make install Make had some problems, won't install Failed during this command: ETHER/Mac-SystemDirectory-0.10.tar.gz : writemakefile NO '/usr/bin/perl Makefile.PL INC=-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE' returned status 6400 |
The Solution Use the MacOS installer command to deploy the needed files:
1 2 3 4 5 |
xcode-select --install sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target / installer: Package name is macOS_SDK_headers_for_macOS_10.14 installer: Installing at base path / installer: The install was successful. |
The, rerunning the cpan install works:
1 2 3 4 5 6 7 8 9 10 11 |
cpan[1]> install Mac::SystemDirectory ... Running make install Files found in blib/arch: installing files in blib/lib into architecture dependent library tree Installing /Library/Perl/5.18/darwin-thread-multi-2level/auto/Mac/SystemDirectory/SystemDirectory.bs Installing /Library/Perl/5.18/darwin-thread-multi-2level/auto/Mac/SystemDirectory/SystemDirectory.bundle Installing /Library/Perl/5.18/darwin-thread-multi-2level/Mac/SystemDirectory.pm Installing /usr/local/share/man/man3/Mac::SystemDirectory.3pm Appending installation info to /Library/Perl/Updates/5.18.2/darwin-thread-multi-2level/perllocal.pod ETHER/Mac-SystemDirectory-0.10.tar.gz /usr/bin/make install -- OK |