macOS 10.12 brew install openssl 问题

vin*_*man 14 macos homebrew openssl

尝试使用以下命令在自制软件上安装 openssl:

brew install openssl
Run Code Online (Sandbox Code Playgroud)

在make过程中出现以下错误:

clang  -I. -Iinclude -fPIC -arch x86_64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/usr/local/etc/openssl@1.1\"" -DENGINESDIR="\"/usr/local/Cellar/openssl@1.1/1.1.1l/lib/engines-1.1\"" -D_REENTRANT -DNDEBUG  -MMD -MF crypto/rand/randfile.d.tmp -MT crypto/rand/randfile.o -c -o crypto/rand/randfile.o crypto/rand/randfile.c
In file included from crypto/rand/rand_unix.c:38:
/usr/include/CommonCrypto/CommonRandom.h:35:9: error: unknown type name 'CCCryptorStatus'
typedef CCCryptorStatus CCRNGStatus;
        ^
crypto/rand/rand_unix.c:385:47: error: use of undeclared identifier 'kCCSuccess'
    if (CCRandomGenerateBytes(buf, buflen) == kCCSuccess)
                                              ^
2 errors generated.
make[1]: *** [crypto/rand/rand_unix.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [all] Error 2

Do not report this issue to Homebrew/brew or Homebrew/core!
Run Code Online (Sandbox Code Playgroud)

Brew 正在尝试安装 openssl 1.1.1l:

==> Downloading https://www.openssl.org/source/openssl-1.1.1l.tar.gz
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/b6ccc5a2a602c2af3480bbcf1656bd9844595974ba60501871ac12504508e818--openssl-1.1.1l.tar.gz
Run Code Online (Sandbox Code Playgroud)

我需要此依赖项来安装许多其他应用程序/工具,例如 wget 或 python - 并希望使用自制软件来执行此操作。

我使用的 brew 版本是:

Homebrew 3.2.9
Homebrew/homebrew-core (git revision fa395c6627; last commit 2021-08-27)
Homebrew/homebrew-cask (git revision 606ed52390; last commit 2021-08-27)
Run Code Online (Sandbox Code Playgroud)

macOS 是:10.12.6 (Sierra),我使用的是 MacBook Pro(13 英寸,2011 年初)

有什么办法可以解决这个问题来安装openssl?或者无论如何我可以安装python指定不同的openssl作为依赖项使用?

我能够使用以下 brew 命令安装 openssl 1.0:

brew install rbenv/tap/openssl@1.0
Run Code Online (Sandbox Code Playgroud)

但是,python 不断尝试使用由于上述错误而失败的 openssl 1.1.1l。

小智 22

我设法通过编辑公式 ( brew edit openssl) 并添加

-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
Run Code Online (Sandbox Code Playgroud)

到 args 数组中configure_args

如下:

  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
Run Code Online (Sandbox Code Playgroud)

  • 这在 OS X 10.13 High Sierra 上为我解决了这个问题。谢谢! (2认同)
  • 10.13 High Sierra 非常适合我。谢谢@Hulkur。 (2认同)
  • 谢谢,它也可以在我的 Mac 10.13.6 上运行。需要15分钟才能完成 (2认同)

小智 9

我必须在 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
Run Code Online (Sandbox Code Playgroud)

我在声明之前添加了以下行typedef

#include "CommonCrypto/CommonCryptoError.h"
Run Code Online (Sandbox Code Playgroud)

并且还遵循@Hulkur的建议 - 运行命令:

brew edit openssl
Run Code Online (Sandbox Code Playgroud)

并添加了

-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include 
Run Code Online (Sandbox Code Playgroud)

排列argsconfigure_args.