Fix Missing Headers Compiling on macOS Mojave
- Comments:
- 26
- Tags:
- Xcode
- Walkthrough
- PHP
- MacOS
While trying to compile PHP extensions after installing macOS Mojave, I was butting up against a ton of missing header file errors including php.h
and zlib.
After several hours of beating my head against my desk and Googling/Stack Overflowing I found the solution.
Ends up you just need to force re-install the header files. Special thanks to @sfdye for the solution!
$ sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
If you get an error about that file not existing, you probably simply don't have the Xcode command line tools installed which can be remedied simply as follows:
$ xcode-select --install
Comment by: Matthew Koski on
Thank you so much for this! Google please make this the number one result when someone is having trouble with headers suddenly on Mojave. For me it was ctypes.h.
Comment by: Ali on
After beating my head to against my desk, walls, laptop, and every single thing around me for a whole week, finally got the answer to the damn problem.
Thank you Jesse. You saved my life.
Thank you Jesse. You saved my life.
Comment by: igonejack on
```
cd /Library/Developer/CommandLineTools/Packages
open macOS_SDK_headers_for_macOS_xx.pgk
```
Try this if you still missing C headers.
cd /Library/Developer/CommandLineTools/Packages
open macOS_SDK_headers_for_macOS_xx.pgk
```
Try this if you still missing C headers.
Comment by: michel on
I get :
installer: Error - the package path specified was invalid: '/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg'.
whats wrong?
installer: Error - the package path specified was invalid: '/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg'.
whats wrong?
Comment by: Brian Eng on
I found a solution that works for me. With 10.14.5, the
'/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg' package is removed.
Instead you have to point it to where the headers are in the Xcode package. In my .bash_profile I added this:
export CPATH="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include"
'/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg' package is removed.
Instead you have to point it to where the headers are in the Xcode package. In my .bash_profile I added this:
export CPATH="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include"
Comment by: mech on
https://stackoverflow.com/questions/54828310/problems-installing-mysql2-gem
Maybe use this?
bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib"
Maybe use this?
bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib"
Comment by: Ben Smith on
Thanks for posting this!
A gotcha I ran into is xcode-select was already installed but without header files. To correct this remove the old command line tools with:
$ (sudo) rm -rf /Library/Developer/CommandLineTools
Then install command line tooks ala:
$ xcode-select --install
Then finally your header file line.
A gotcha I ran into is xcode-select was already installed but without header files. To correct this remove the old command line tools with:
$ (sudo) rm -rf /Library/Developer/CommandLineTools
Then install command line tooks ala:
$ xcode-select --install
Then finally your header file line.
Comment by: Z Knight on
This file does not exist!
Why is this working for so many people but not me???
$ sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
installer: Error - the package path specified was invalid: '/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg'.
$ ll /Library/Developer/CommandLineTools/
total 0
drwxr-xr-x 6 root admin 192 Jun 5 01:52 Library
drwxr-xr-x 6 root wheel 192 Jun 5 01:52 SDKs
drwxr-xr-x 7 root admin 224 Oct 19 2018 usr
Why is this working for so many people but not me???
$ sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
installer: Error - the package path specified was invalid: '/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg'.
$ ll /Library/Developer/CommandLineTools/
total 0
drwxr-xr-x 6 root admin 192 Jun 5 01:52 Library
drwxr-xr-x 6 root wheel 192 Jun 5 01:52 SDKs
drwxr-xr-x 7 root admin 224 Oct 19 2018 usr
Comment by: l on
@z Knight I had the same issue with mine - I went to https://developer.apple.com/download/more/ and downloaded the Command Line Tools (macOS 10.14) for Xcode 10.3 June 22, 2019.
This added the .pkg to the file. however it didn't fix the issue I was having (being told I need to install development tools first).
This added the .pkg to the file. however it didn't fix the issue I was having (being told I need to install development tools first).
Comment by: Micha on
When using
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target / -allowUntrusted
i get the error:
installer: The install failed (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance.)
Mac OS 10.14.6
If I don't add "-allowUntrusted", it states "Certificate used to sign package is not trusted.".
Does anybody else have the same problem?
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target / -allowUntrusted
i get the error:
installer: The install failed (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance.)
Mac OS 10.14.6
If I don't add "-allowUntrusted", it states "Certificate used to sign package is not trusted.".
Does anybody else have the same problem?
Comment by: Jeff Bonhag on
I found this page Googling a similar problem for Nokogiri so I thought I would share another hard-won lesson on macOS gembuilding.
On macOS Catalina, while trying to bundle install a Gemfile with a Nokogiri dependency, I kept hitting:
> libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
Solution:
brew install libiconv
bundle config build.nokogiri --with-iconv-dir=/usr/local/opt/libiconv
bundle install --path vendor/bundle
Cheers!
On macOS Catalina, while trying to bundle install a Gemfile with a Nokogiri dependency, I kept hitting:
> libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
Solution:
brew install libiconv
bundle config build.nokogiri --with-iconv-dir=/usr/local/opt/libiconv
bundle install --path vendor/bundle
Cheers!
Comment by: MacrossEO on
Im using MacOS 10.14.5
For me, the solution was:
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
cd /Library/Developer/CommandLineTools/Packages/
open macOS_SDK_headers_for_macOS_10.14.pkg
Cheers!
For me, the solution was:
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
cd /Library/Developer/CommandLineTools/Packages/
open macOS_SDK_headers_for_macOS_10.14.pkg
Cheers!
Comment by: bb cody on
4-liner above worked for me, posted by MacrossEO on Nov. 28, 2019
my own context was for local ruby build for heroku app,
in which ruby.h was not found because mac os xcode upgrade
dropped its default install of (some? all?) include files;
in order to get a successful
bundle install
and specifically
sudo gem install nokogiri -v '1.10.4' --source 'https://rubygems.org/'
my own context was for local ruby build for heroku app,
in which ruby.h was not found because mac os xcode upgrade
dropped its default install of (some? all?) include files;
in order to get a successful
bundle install
and specifically
sudo gem install nokogiri -v '1.10.4' --source 'https://rubygems.org/'
Comment by: Hari on
May be because I use DuckDuckGo -- this came up in the first few links! Thanks, helped me sort out why 'gem <> install --user-install'
Comment by: annoporci on
Tried MacrossEO's suggestion, but to begin with I have no `Packages` subdirectory under `CommandLineTools`, instead I have:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
Is there anything I could try next? Thanks.
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
Is there anything I could try next? Thanks.
Comment by: João on
I have the same issue. No Packages folder,, just:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
macOS 10.15 (Catalina)
I keep getting this error when compiling: fatal error: 'string.h' file not found...
Thanks
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
macOS 10.15 (Catalina)
I keep getting this error when compiling: fatal error: 'string.h' file not found...
Thanks
Comment by: Madhusudan D Sangam on
Hi Everyone,
Hope all are well and Safe,
as anooprci and Joao, i am also facing the similar issue,
is there any way to fix it,
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
macOS 10.15 (Catalina)
How to fix it.
Hope all are well and Safe,
as anooprci and Joao, i am also facing the similar issue,
is there any way to fix it,
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
macOS 10.15 (Catalina)
How to fix it.
Comment by: Sadhakka on
I'm fighting with same problem.
`export CPATH="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include"`
not helped, and after reinstall xcode old version (MacOSX10.14.sdk) is gone
`export CPATH="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include"`
not helped, and after reinstall xcode old version (MacOSX10.14.sdk) is gone
Comment by: Yujuan Gui on
This works for me.
I have macOS Catalina 10.15.6
https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos/
I have macOS Catalina 10.15.6
https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos/
Comment by: Valera on
With Catalina 10.15 I've added the line below to my ~/.bash_profile:
export CPATH="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
Check twice, that this path exists. There are might be some variants, e.g. MacOSX10.14.sdk or MacOSX10.15.sdk
export CPATH="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
Check twice, that this path exists. There are might be some variants, e.g. MacOSX10.14.sdk or MacOSX10.15.sdk
Comment by: Ella on
I found this page Googling a similar problem for Nokogiri so I thought I would share another hard-won lesson on macOS building. The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance. Thank you so much for this! Google please make this the number one result when someone is having trouble with headers suddenly on Mojave.
https://www.ornamentsbyelves.com/sports-activities/hiking-and-climbing.html
https://www.ornamentsbyelves.com/sports-activities/hiking-and-climbing.html