首頁  >  文章  >  後端開發  >  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刪除