5

I'm trying to build my Rust project using "anchor build", but I get this error message in the terminal

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

Caused by:
  process didn't exit successfully: `/home/rokasb/bachelor-project/kratos/target/release/build/openssl-sys-9488c608e06265da/build-script-main` (exit status: 101)
  --- stdout
  cargo:rustc-cfg=const_fn
  cargo:rerun-if-env-changed=BPFEL_UNKNOWN_UNKNOWN_OPENSSL_NO_VENDOR
  BPFEL_UNKNOWN_UNKNOWN_OPENSSL_NO_VENDOR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
  OPENSSL_NO_VENDOR unset

  --- stderr
  thread 'main' panicked at 'don't know how to configure OpenSSL for bpfel-unknown-unknown', /home/rokasb/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-src-111.18.0+1.1.1n/src/lib.rs:283:18
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed

This are my dependencies and features in Cargo.toml file:

[dependencies]
anchor-lang = "0.21.0"
openssl = { version = "0.10", features = ["vendored"] }

[features]
no-entrypoint = []
no-idl = []
no-log-ix-name = []
cpi = ["no-entrypoint"]
default = []
vendored-openssl = ["openssl/vendored"]

It feels like I have tried everything to get openssl work in my project, but it always fails to build. I'm using Manjaro Linux. Any ideas what I could do to fix this problem and make openssl work with Rust?

I have tried following:

  • changing PKG_CONFIG_PATH and OPENSSL_DIR manually
  • updating rust with rustup update
  • deleting and installing openssl with different versions (using pacman)
  • running this command sudo pacman -S pkg-config openssl
  • changing dependencies in Cargo.toml to: [dependencies] openssl-sys = "0.9" openssl = "0.10"
  • setting PKG_CONFIG_ALLOW_CROSS=1
  • I don't know what Anchor is, but it's not what the [tag:anchor] tag is for. – trent Apr 01 '22 at 15:18
  • Anchor is a framework for Solana developers. https://project-serum.github.io/anchor/getting-started/introduction.html – Rokas Bliudzius Apr 03 '22 at 10:23
  • what install command are you using to install Anchor? – DaveTheAl Apr 18 '22 at 14:54
  • @DaveTheAl I followed this installation manual: https://project-serum.github.io/anchor/getting-started/installation.html#install-using-pre-build-binary-on-x86-64-linux, but I used yarn instead of npm if I remember correctly. When I run "anchor --version" command, I get this version: anchor-cli 0.21.0. – Rokas Bliudzius Apr 21 '22 at 09:14

2 Answers2

2

Try to install libssl-dev :

sudo apt-get install libssl-dev
KotlinIsland
  • 799
  • 1
  • 6
  • 25
  • 1
    I'm using Arch Linux (Manjaro), so I'm unable to install this package. The arch openssl package contains all the dev parts by default, so I should not need to install libssl-dev either. – Rokas Bliudzius Apr 03 '22 at 10:30
1

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

Benyam
  • 329
  • 4
  • 6