【问题标题】:macOS 10.12 brew install openssl issuemacOS 10.12 brew install openssl 问题
【发布时间】:2021-10-27 15:49:34
【问题描述】:

尝试在 homebrew 上安装 openssl:

brew install openssl

在制作过程中出现以下错误:

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!

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

我需要此依赖项来安装许多其他应用程序/工具,例如 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)

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

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

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

brew install rbenv/tap/openssl@1.0

但是,python 不断尝试使用 openssl 1.1.1l 失败并出现上述错误。

【问题讨论】:

  • 我在 macOS 10.13.6 上也遇到了同样的错误。尝试安装 gdal 依赖,numpy。它需要 openssl@1.1

标签: macos openssl homebrew


【解决方案1】:

似乎是 openssl 本身的错误。 https://github.com/openssl/openssl/issues/16487


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


适用于某些 macOS 版本的 Homebrew 预构建包。但它不断放弃对旧 macOS 的预构建支持。在 macOS 10.12 上,您正在从源代码构建 openssl,并且需要 Xcode 命令行工具

xcode-select --install

然后再次brew install openssl

【讨论】:

  • 就我而言,我安装了 xcode 9.4,但在安装 openssl 时仍然失败。
  • @user97103 Xcode 不是 Xcode 命令行工具的超集。您仍然需要安装 Xcode CLT 以获取相关库。在这种情况下,/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/CommonCrypto 是必需的。
  • 我在添加 xcode 之前确实安装了 clt,因为它是 homebrew 所需要的
  • 不幸的是,安装 xcode 命令行工具不是问题 - 这已经安装了。我也有您在上面突出显示的路径:/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/CommonCrypto - 但是,在 make/compile 期间,brew 似乎正在使用 /usr/include/CommonCrypto/CommonRandom.h 中的版本 - 无论如何强制 brew 使用 XCode CLT 依赖项进行安装?
【解决方案2】:

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

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

configure_args中的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

【讨论】:

  • 这在 OS X 10.13 High Sierra 上为我解决了这个问题。谢谢!
  • 请问在哪里添加?
  • 10.13 High Sierra 对我来说很棒。谢谢@Hulkur。
  • 这也解决了我的问题。我确实必须配置我的 brew 编辑器 --export HOMEBREW_EDITOR="/usr/bin/vim" -- 添加到 .zshrc 或 .bashrc。之后,'brew edit openssl' 起作用了。在文件中找到“configure_args”并在右括号之前添加上述行(即])
  • 谢谢,我的 Mac 10.13.6 也可以。完成需要 15 分钟
【解决方案3】:

首先,编辑文件:

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

然后

brew edit openssl

文件打开后添加该行 -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

保存版本并安装

brew install openssl 

注意:安装花了很长时间,但已经成功了。

【讨论】:

    【解决方案4】:

    我不得不在 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
    

    我在typedef 语句之前添加了以下行:

    #include "CommonCrypto/CommonCryptoError.h"
    

    并且还听从了@Hulkur 的建议——运行命令:

    brew edit openssl
    

    并添加

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

    configure_args 中的args 数组。

    【讨论】:

    • 这解决了我在 MacOS Sierra 上的问题
    【解决方案5】:

    在 brew edit openssl 之后,我得到了一个新的错误:

    => perl ./Configure --prefix=/usr/local/Cellar/openssl@1.1/1.1.1l --openssldir=/usr/local/etc/openssl@1.1 no-ssl3 no-ssl3-method no-zlib -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include darwin64-x86_64-cc enable-ec_nistp_64_gcc_128
    ==> make
    Last 15 lines from /Users/francis/Library/Logs/Homebrew/openssl@1.1/02.make:
    include "CommonCrypto/CommonCryptoError.h"
    ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/CommonCrypto/CommonRandom.h:35:9: error: expected identifier or '('
    include "CommonCrypto/CommonCryptoError.h"
            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/CommonCrypto/CommonRandom.h:52:1: error: unknown type name 'CCRNGStatus'
    CCRNGStatus CCRandomGenerateBytes(void *bytes, size_t count)
    ^
    crypto/rand/rand_unix.c:385:47: error: use of undeclared identifier 'kCCSuccess'
        if (CCRandomGenerateBytes(buf, buflen) == kCCSuccess)
                                                  ^
    4 errors generated.
    make[1]: *** [crypto/rand/rand_unix.o] Error 1
    make[1]: *** Waiting for unfinished jobs....
    make: *** [all] Error 2
    

    编辑

    愚蠢的我,我有:

    include "CommonCrypto/CommonCryptoError.h"
    

    代替

    #include "CommonCrypto/CommonCryptoError.h"
    

    所以先确保你有一个哈希值。

    【讨论】:

      【解决方案6】:

      此问题现已解决(自 2021 年 9 月 11 日起),不再需要补丁

      【讨论】:

      • 不正确。问题依然存在。
      【解决方案7】:

      对于 10.12 之前的 MacOS(例如 10.11 El Capitan),还有另一个问题 - 测试失败:

      Test Summary Report
      -------------------
      ../test/recipes/05-test_rand.t (Wstat: 256 Tests: 2 Failed: 1)
        Failed test:  1
        Non-zero exit status: 1
      Files=1, Tests=2,  5 wallclock secs ( 0.38 usr  0.06 sys +  5.71 cusr  2.48 csys =  8.63 CPU)
      Result: FAIL
      make[1]: *** [_tests] Error 1
      make: *** [tests] Error 2
      

      OpenSSL 存在一个问题和一个拉取请求,可以解决此问题: https://github.com/openssl/openssl/issues/16517

      https://github.com/openssl/openssl/pull/16587

      如果你有这个问题,请过去投票给他们

      【讨论】:

        猜你喜欢
        • 2021-10-31
        • 1970-01-01
        • 2019-07-20
        • 2018-03-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-02-03
        相关资源
        最近更新 更多