Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error build Rust for linux in macos - Openssl

Trying to compile for linux from a mac throws this error, I have openssl and pkg-config installed from brew.

And in the file ~/.cargo/config I have this configuration.

[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"

Error:

error: failed to run custom build command for `openssl-sys v0.9.72`

Caused by:
  process didn't exit successfully: `/Users/Proyect/cvm/target/release/build/openssl-sys-66182f9fe15cdddc/build-script-main` (exit status: 101)
  run pkg_config fail: "`\"pkg-config\" \"--libs\" \"--cflags\" \"openssl\"` did not exit successfully: exit status: 1\nerror: could not find system library 'openssl' required by the 'openssl-sys' crate\n\n--- stderr\nPackage openssl was not found in the pkg-config search path.\nPerhaps you should add the directory containing `openssl.pc'\nto the PKG_CONFIG_PATH environment variable\nNo package 'openssl' found\n"

  --- stderr
  thread 'main' panicked at '

  Could not find directory of OpenSSL installation, and this `-sys` crate cannot
  proceed without this knowledge. If OpenSSL is installed and this crate had
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
  compilation process.

  Make sure you also have the development packages of openssl installed.
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.

  If you're in a situation where you think the directory *should* be found
  automatically, please open a bug at https://github.com/sfackler/rust-openssl
  and include information about your system as well as this message.

  $HOST = x86_64-apple-darwin
  $TARGET = x86_64-unknown-linux-gnu
  openssl-sys = 0.9.72

  ', /Users/user/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.72/build/find_normal.rs:180:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
like image 938
Orelvis Lago Avatar asked May 24 '26 18:05

Orelvis Lago


1 Answers

The error message contains three possible solutions:

First make sure it is really installed including for development (which is what you need if you want to compile code against openssl):

Make sure you also have the development packages of openssl installed. For example, libssl-dev on Ubuntu or openssl-devel on Fedora.

If it is already really installed, then it could not be found. This can be fixed by adding the directory containing `openssl.pc' to the PKG_CONFIG_PATH environment variable:

Package openssl was not found in the pkg-config search path. Perhaps you should add the directory containing `openssl.pc' to the PKG_CONFIG_PATH environment variable.

Or by setting the OPENSSL_DIR to point to where the openssl code is on your system:

Could not find directory of OpenSSL installation, and this -sys crate cannot proceed without this knowledge. If OpenSSL is installed and this crate had trouble finding it, you can set the OPENSSL_DIR environment variable for the compilation process.

like image 103
hkBst Avatar answered May 27 '26 09:05

hkBst



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!