由于 Mac 操作系统提供 LibreSSL 而非 openssl,故遇到编译问题需要自行安装和激活 openssl
安装 openssl 依赖
$ brew install openssl
查看 openssl 信息
$ brew info openssl
openssl@3: stable 3.0.2 (bottled) [keg-only]
Cryptography and SSL/TLS Toolkit
https://openssl.org/
/usr/local/Cellar/openssl@3/3.0.2 (6,429 files, 28.2MB)
Poured from bottle on 2022-04-28 at 12:56:15
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/openssl@3.rb
License: Apache-2.0
==> Dependencies
Required: ca-certificates ✔
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
/usr/local/etc/openssl@3/certs
and run
/usr/local/opt/openssl@3/bin/c_rehash
openssl@3 is keg-only, which means it was not symlinked into /usr/local,
because macOS provides LibreSSL.
If you need to have openssl@3 first in your PATH, run:
echo 'export PATH="/usr/local/opt/openssl@3/bin:$PATH"' >> ~/.zshrc
For compilers to find openssl@3 you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"
For pkg-config to find openssl@3 you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"
配置环境变量
根据以上打印信息,在~/.zshrc
(或其他)配置环境变量
export PATH="/usr/local/opt/openssl@3/bin:$PATH"
export CPATH=/usr/local/opt/openssl@3/include:"${CPATH}"
export PKG_CONFIG_PATH=/usr/local/opt/openssl@3/lib/pkgconfig:"${PKG_CONFIG_PATH}"
export LD_LIBRARY_PATH=/usr/local/opt/openssl@3/lib:"${LD_LIBRARY_PATH}"
激活环境完成
$ source ~/.zshrc
网友评论