macOS 10.12 brew install openssl issue

Solution 1:

I managed to resolve it by editing formula (brew edit openssl) and adding

-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include

to args array in configure_args.

As below:

  def configure_args
    args = %W[
      --prefix=#{prefix}
      --openssldir=#{openssldir}
      no-ssl3
      no-ssl3-method
      no-zlib
      ##### add the line here ####
      -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
    ]
    on_linux do
      args += (ENV.cflags || "").split
      args += (ENV.cppflags || "").split
      args += (ENV.ldflags || "").split
      args << "enable-md2"
    end
    args
  end

Solution 2:

I had to change the following file on Sierra (MacOs 10.12):

sudo chmod a+w /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/CommonCrypto/CommonRandom.h

vi /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/CommonCrypto/CommonRandom.h

I've added the following line before the typedef statement:

#include "CommonCrypto/CommonCryptoError.h"

And also followed the advice of @Hulkur - run command:

brew edit openssl

and added

-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include 

to args array in configure_args.

Solution 3:

Seems a bug of openssl itself. https://github.com/openssl/openssl/issues/16487


~~What about export SDKROOT="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk "?~~


Homebrew pre-build packages for some versions of macOS. But it keep dropping this pre-building support for old macOS. On macOS 10.12, you're building openssl from the source code and Xcode command line tool is needed.

xcode-select --install

Then brew install openssl again.

Solution 4:

First, to edit the file:

$ export EDITOR=nano
$ export VISUAL="$EDITOR"

then

brew edit openssl

After file open add the line -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include

 # help debug inevitable breakage.
  def configure_args
    args = %W[
      --prefix=#{prefix}
      --openssldir=#{openssldir}
      no-ssl3
      no-ssl3-method
      no-zlib
      -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
    ]
    on_linux do
      args += (ENV.cflags || "").split
      args += (ENV.cppflags || "").split
      args += (ENV.ldflags || "").split
      args << "enable-md2"
    end
    args
  end

Save edition and install

brew install openssl 

Notice: the installation took a long time, but it's worked.