Home > Backend Development > Golang > openssl error ld: warning: directory not found for option '-L/usr/local/opt/openssl/lib'

openssl error ld: warning: directory not found for option '-L/usr/local/opt/openssl/lib'

王林
Release: 2024-02-10 14:24:09
forward
1098 people have browsed it

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

php editor Banana encountered an error when using openssl, prompting "ld: warning: option '-L/usr/local/opt/openssl/lib' not found Table of contents". This error is usually caused by the openssl library file path being incorrectly configured. The solution to this problem is to add the correct openssl library file path in the compilation options.

Problem content

An error occurred while compiling the tdlib program related to openssl call.

/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)
Copy after login

openssl is installed with brew:

which openssl
/opt/homebrew/bin/openssl
Copy after login
==> 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
Copy after login

I tried using pkg-config and exposing the next environment to resolve this issue, but nothing helped.

export CGO_CFLAGS=$(pkg-config --cflags openssl)
export CGO_LDFLAGS=$(pkg-config --libs openssl)
Copy after login

Workaround

Can you also check these flags (.~/bashrc or ~/.zshrc):

export CGO_CFLAGS="-I/opt/homebrew/include"
export CGO_LDFLAGS="-L/opt/homebrew/lib -lssl -lcrypto"
Copy after login

Or you can use pkg-config:

export CGO_CFLAGS="$(pkg-config --cflags openssl)"
export CGO_LDFLAGS="$(pkg-config --libs openssl)"
Copy after login

The above is the detailed content of openssl error ld: warning: directory not found for option '-L/usr/local/opt/openssl/lib'. For more information, please follow other related articles on the PHP Chinese website!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template