编译与 openssl 调用相关的 tdlib 程序时出现错误。
/opt/homebrew/opt/go/libexec/pkg/tool/darwin_arm64/link: running cc failed: exit status 1 ld: warning: directory not found for option '-L/usr/local/opt/openssl/lib' ld: library not found for -lssl clang: error: linker command failed with exit code 1 (use -v to see invocation)
openssl 已随brew 安装:
which openssl /opt/homebrew/bin/openssl
==> openssl@3: stable 3.1.2 (bottled) Cryptography and SSL/TLS Toolkit https://openssl.org/ /opt/homebrew/Cellar/openssl@3/3.1.2 (6,495 files, 28.4MB) * Poured from bottle using the formulae.brew.sh API on 2023-09-21 at 14:06:03 From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/o/[email protected] License: Apache-2.0
我尝试使用 pkg-config 并暴露下一个环境来解决此问题,但没有任何帮助。
export CGO_CFLAGS=$(pkg-config --cflags openssl) export CGO_LDFLAGS=$(pkg-config --libs openssl)
你也可以检查这些标志吗(.~/bashrc 或 ~/.zshrc):
export CGO_CFLAGS="-I/opt/homebrew/include" export CGO_LDFLAGS="-L/opt/homebrew/lib -lssl -lcrypto"
或者你可以使用pkg-config:
export CGO_CFLAGS="$(pkg-config --cflags openssl)" export CGO_LDFLAGS="$(pkg-config --libs openssl)"