首页  >  文章  >  后端开发  >  openssl 错误 ld:警告:找不到选项 '-L/usr/local/opt/openssl/lib 的目录

openssl 错误 ld:警告:找不到选项 '-L/usr/local/opt/openssl/lib 的目录

王林
王林转载
2024-02-10 14:24:091013浏览

openssl 错误 ld:警告:找不到选项 '-L/usr/local/opt/openssl/lib 的目录

php小编香蕉在使用openssl时遇到了一个错误,提示"ld:警告:找不到选项'-L/usr/local/opt/openssl/lib'的目录"。这个错误通常是由于openssl的库文件路径未正确配置所导致的。解决这个问题的方法是在编译选项中添加正确的openssl库文件路径。

问题内容

编译与 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)"

以上是openssl 错误 ld:警告:找不到选项 '-L/usr/local/opt/openssl/lib 的目录的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文转载于:stackoverflow.com。如有侵权,请联系admin@php.cn删除