Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ubuntu 18: failed to run custom build command for openssl-sys v0.9.39 #1021

Closed
karasjoh000 opened this issue Nov 24, 2018 · 49 comments
Closed

Comments

@karasjoh000
Copy link

installed libssl-dev on ubuntu 18 and still get this error:
error: failed to run custom build command for openssl-sys v0.9.39
process didn't exit successfully: /home/forecast/cs453_finalproj_backend/target/release/build/openssl-sys-864259d0b1f702fc/build-script-main (exit code: 101)

@karasjoh000
Copy link
Author

karasjoh000 commented Nov 24, 2018

might be same as #994 but too many comments there, can't find what will actually work

1.1.0g-2ubuntu4.1

@sfackler
Copy link
Owner

What does the rest of the error message say? In particular, you need pkg-config installed.

@karasjoh000
Copy link
Author

elease
Compiling openssl-sys v0.9.39
error: failed to run custom build command for openssl-sys v0.9.39
process didn't exit successfully: /home/forecast/cs453_finalproj_backend/target/release/build/openssl-sys-864259d0b1f702fc/build-script-main (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR
cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR
cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR
cargo:rerun-if-env-changed=OPENSSL_DIR
run pkg_config fail: "Failed to run \"pkg-config\" \"--libs\" \"--cflags\" \"openssl\": No such file or directory (os error 2)"

--- 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-unknown-linux-gnu
$TARGET = x86_64-unknown-linux-gnu
openssl-sys = 0.9.39

It looks like you're compiling on Linux and also targeting Linux. Currently this
requires the pkg-config utility to find OpenSSL but unfortunately pkg-config
could not be found. If you have OpenSSL installed you can likely fix this by
installing pkg-config.

', /home/forecast/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.39/build/main.rs:269:9
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:71
2: std::panicking::default_hook::{{closure}}
at src/libstd/sys_common/backtrace.rs:59
at src/libstd/panicking.rs:211
3: std::panicking::default_hook
at src/libstd/panicking.rs:227
4: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:476
5: std::panicking::begin_panic
6: build_script_main::imp::get_openssl
7: build_script_main::main
8: std::rt::lang_start::{{closure}}
9: std::panicking::try::do_call
at src/libstd/rt.rs:59
at src/libstd/panicking.rs:310
10: __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:102
11: std::rt::lang_start_internal
at src/libstd/panicking.rs:289
at src/libstd/panic.rs:398
at src/libstd/rt.rs:58
12: main
13: __libc_start_main
14: _start

@karasjoh000
Copy link
Author

so how do I configure pkg-config

@karasjoh000
Copy link
Author

Works now, ran sudo apt install pkg-config

@agryaznov
Copy link

Works now, ran sudo apt install pkg-config

Didn't help in my case. What helped was to get that openssl library sources and build it ourselves

See the full list of commands here

@ssainball
Copy link

Works now, ran sudo apt install pkg-config

Thank you very much. from Korea.

@lechatthecat
Copy link

I'm using Ubuntu and the error message says:

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

So I installed it:

sudo apt install libssl-dev

And it is working now.

lovasoa added a commit to lovasoa/dezoomify-rs that referenced this issue Mar 19, 2020
@ashWhiteHat
Copy link

ashWhiteHat commented Mar 29, 2020

I fix this problem to add.

Cargo.toml

[dependencies]
openssl = { version = "0.10", features = ["vendored"] }

@LeonidKrutovsky
Copy link

That's what helped me (on several ubuntu systems)

sudo apt install openssl1.0 libssl1.0.0 libssl1.0-dev
cargo clean
OPENSSL_LIB_DIR="/usr/lib/x86_64-linux-gnu" 
OPENSSL_INCLUDE_DIR="/usr/include/openssl" 
cargo build

@singularidadedigital
Copy link

I'm using Ubuntu and the error message says:

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

So I installed it:

sudo apt install libssl-dev

And it is working now.

works for me, thanks

@bolerap
Copy link

bolerap commented Nov 12, 2020

I'm using Ubuntu and the error message says:

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

So I installed it:

sudo apt install libssl-dev

And it is working now.

Works for me, thanks

@mybee
Copy link

mybee commented May 15, 2021

thanks, sudo apt install libssl-dev and sudo apt install pkg-config

@LeoniePhiline
Copy link

For Googlers:

On OpenSUSE (e.g. Tumbleweed) run sudo zypper install libopenssl-devel

@benniebendiksen
Copy link

I fix this problem to add.

Cargo.toml

[dependencies]
openssl = { version = "0.10", features = ["vendored"] }

Thank you so much!!! After literal hours of struggling, with no prior solution helping me (building a rust project within amazon linux) yours did the trick!

@riteshkumargiitian
Copy link

encountering the same issue.. Does anyone know how to fix the same issue for the "windows " OS ? even if it is some development file then what is command for that please?

@Borregopornz
Copy link

HELP

PS C:\Users\alan1\dougs-bin-example> cargo install cyberdrop-dl
Updating crates.io index
Installing cyberdrop-dl v0.3.2
Compiling proc-macro2 v1.0.34
Compiling unicode-xid v0.2.2
Compiling syn v1.0.82
Compiling winapi v0.3.9
Compiling cfg-if v1.0.0
Compiling autocfg v1.0.1
Compiling getrandom v0.1.16
Compiling proc-macro-hack v0.5.19
Compiling ppv-lite86 v0.2.15
Compiling log v0.4.14
Compiling siphasher v0.3.7
Compiling lazy_static v1.4.0
Compiling libc v0.2.112
Compiling memchr v2.4.1
Compiling pin-project-lite v0.2.7
Compiling futures-core v0.3.17
Compiling ntapi v0.3.6
Compiling itoa v0.4.8
Compiling futures-task v0.3.17
Compiling proc-macro-nested v0.1.7
Compiling serde v1.0.132
Compiling futures-sink v0.3.17
Compiling bytes v1.1.0
Compiling futures-channel v0.3.17
Compiling smallvec v1.7.0
Compiling matches v0.1.9
Compiling futures-io v0.3.17
Compiling parking_lot_core v0.8.5
Compiling slab v0.4.5
Compiling pin-utils v0.1.0
Compiling scopeguard v1.1.0
Compiling fnv v1.0.7
Compiling cc v1.0.72
Compiling new_debug_unreachable v1.0.4
Compiling hashbrown v0.11.2
Compiling pkg-config v0.3.24
Compiling mac v0.1.1
Compiling native-tls v0.2.8
Compiling vcpkg v0.2.15
Compiling tinyvec_macros v0.1.0
Compiling httparse v1.5.1
Compiling precomputed-hash v0.1.1
Compiling percent-encoding v2.1.0
Compiling utf-8 v0.7.6
Compiling try-lock v0.2.3
Compiling dtoa v0.4.8
Compiling nodrop v0.1.14
Compiling stable_deref_trait v1.2.0
Compiling encoding_rs v0.8.30
Compiling serde_json v1.0.73
Compiling bitflags v1.3.2
Compiling tower-service v0.3.1
Compiling httpdate v1.0.2
Compiling ryu v1.0.9
Compiling once_cell v1.9.0
Compiling unicode-bidi v0.3.7
Compiling convert_case v0.4.0
Compiling byteorder v1.4.3
Compiling unicode-width v0.1.9
Compiling openssl v0.10.38
Compiling foreign-types-shared v0.1.1
Compiling itoa v1.0.1
Compiling regex-syntax v0.6.25
Compiling thin-slice v0.1.1
Compiling encode_unicode v0.3.6
Compiling base64 v0.13.0
Compiling utf8-width v0.1.5
Compiling number_prefix v0.4.0
Compiling ipnet v2.3.1
Compiling mime v0.3.16
Compiling ego-tree v0.6.2
Compiling instant v0.1.12
Compiling futures-macro v0.3.17
Compiling futures-util v0.3.17
Compiling indexmap v1.7.0
Compiling phf_shared v0.8.0
Compiling tracing-core v0.1.21
Compiling lock_api v0.4.5
Compiling http v0.2.5
Compiling openssl-src v111.17.0+1.1.1m
Compiling futf v0.1.4
Compiling tinyvec v1.5.1
Compiling form_urlencoded v1.0.1
Compiling dtoa-short v0.3.3
Compiling servo_arc v0.1.1
Compiling fxhash v0.2.1
Compiling getopts v0.2.21
Compiling foreign-types v0.3.2
Compiling byte-unit v4.0.13
Compiling regex v1.5.4
Compiling tracing v0.1.29
Compiling openssl-sys v0.9.72
Compiling tendril v0.4.2
Compiling http-body v0.4.4
Compiling unicode-normalization v0.1.19
Compiling quote v1.0.10
Compiling rand_core v0.5.1
Compiling want v0.3.0
Compiling num_cpus v1.13.0
Compiling miow v0.3.7
Compiling schannel v0.1.19
Compiling socket2 v0.4.2
Compiling terminal_size v0.1.17
Compiling winreg v0.7.0
Compiling idna v0.2.3
Compiling rand_pcg v0.2.1
Compiling rand_chacha v0.2.2
Compiling serde_urlencoded v0.7.0
Compiling parking_lot v0.11.2
Compiling mio v0.7.14
Compiling console v0.15.0
Compiling url v2.2.2
error: failed to run custom build command for openssl-sys v0.9.72

Caused by:
process didn't exit successfully: C:\Users\alan1\AppData\Local\Temp\cargo-installUz4j3n\release\build\openssl-sys-d021080d1b2a556d\build-script-main (exit code: 101)
--- stdout
cargo:rustc-cfg=const_fn
cargo:rerun-if-env-changed=X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR
X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR unset
cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
OPENSSL_NO_VENDOR unset
running "perl" "./Configure" "--prefix=C:\Users\alan1\AppData\Local\Temp\cargo-installUz4j3n\release\build\openssl-sys-294c4342b0e8354b\out\openssl-build\install" "no-dso" "no-shared" "no-ssl3" "no-unit-test" "no-comp" "no-zlib" "no-zlib-dynamic" "no-md2" "no-rc5" "no-weak-ssl-ci
--- stderr
pecified." }', C:\Users\alan1.cargo\registry\src\github.com-1ecc6299db9ec823\openssl-src-111.17.0+1.1.1m\src\lib.rs:477:39
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to compile cyberdrop-dl v0.3.2, intermediate artifacts can be found at C:\Users\alan1\AppData\Local\Temp\cargo-installUz4j3n

Caused by:
build failed

@Borregopornz
Copy link

Im on windows btw );;;

@lowkeyop
Copy link

lowkeyop commented Dec 17, 2021 via email

@TheWeirdDev
Copy link

I had to install librust-openssl-dev on Ubuntu Server 20.04:

sudo apt install librust-openssl-dev

@HsiangSun
Copy link

我正在使用Ubuntu,错误消息说:

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

所以我安装了它:

sudo apt install libssl-dev

它现在正在发挥作用。

Nice it's work on ubuntu 20.04 WSL

@md-ali-scytalelabs
Copy link

I'm using Ubuntu and the error message says:

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

So I installed it:

sudo apt install libssl-dev

And it is working now.

Awesome, Works really fine. Thank you for helping :)

@ghost-in-the-zsh
Copy link

I'm on a fresh Ubuntu 22.04 LTS install and I'm still running into this issue. (As far as I can recall, my old machine, which had started with 18.04 and upgraded its way to 22.04 never ran into this issue.) The following packages are automatically included in 22.04 already: pgk-config, build-essential. I manually installed the libssl-dev package and also tried with librust-openssl-dev, as suggested in a prior comment, but there was no difference.

$ cargo build
   Compiling openssl-sys v0.9.63
   Compiling http-body v0.4.1
   Compiling syn v1.0.89
   Compiling tokio v1.5.0
   Compiling proc-macro-error-attr v1.0.4
   Compiling idna v0.2.3
   Compiling num-integer v0.1.44
   Compiling regex v1.5.3
The following warnings were emitted during compilation:

warning: build/expando.c:4:24: error: pasting "RUST_VERSION_OPENSSL_" and "(" does not give a valid preprocessing token
warning:     4 | #define VERSION2(n, v) RUST_VERSION_##n##_##v
warning:       |                        ^~~~~~~~~~~~~
warning: build/expando.c:5:23: note: in expansion of macro ‘VERSION2’
warning:     5 | #define VERSION(n, v) VERSION2(n, v)
warning:       |                       ^~~~~~~~
warning: build/expando.c:10:1: note: in expansion of macro ‘VERSION’
warning:    10 | VERSION(OPENSSL, OPENSSL_VERSION_NUMBER)
warning:       | ^~~~~~~

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

Caused by:
  process didn't exit successfully: <redacted-path> (exit status: 101)
  --- stdout
  cargo:rustc-cfg=const_fn
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
  OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
  OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_DIR
  OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=OPENSSL_STATIC
  cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=SYSROOT
  cargo:rerun-if-env-changed=OPENSSL_STATIC
  cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rustc-link-lib=ssl
  cargo:rustc-link-lib=crypto
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=OPENSSL_STATIC
  cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  OPT_LEVEL = Some("0")
  TARGET = Some("x86_64-unknown-linux-gnu")
  HOST = Some("x86_64-unknown-linux-gnu")
  CC_x86_64-unknown-linux-gnu = None
  CC_x86_64_unknown_linux_gnu = None
  HOST_CC = None
  CC = None
  CFLAGS_x86_64-unknown-linux-gnu = None
  CFLAGS_x86_64_unknown_linux_gnu = None
  HOST_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-I" "/usr/include" "-Wall" "-Wextra" "-E" "build/expando.c"
  cargo:warning=build/expando.c:4:24: error: pasting "RUST_VERSION_OPENSSL_" and "(" does not give a valid preprocessing token
  cargo:warning=    4 | #define VERSION2(n, v) RUST_VERSION_##n##_##v
  cargo:warning=      |                        ^~~~~~~~~~~~~
  cargo:warning=build/expando.c:5:23: note: in expansion of macro ‘VERSION2’
  cargo:warning=    5 | #define VERSION(n, v) VERSION2(n, v)
  cargo:warning=      |                       ^~~~~~~~
  cargo:warning=build/expando.c:10:1: note: in expansion of macro ‘VERSION’
  cargo:warning=   10 | VERSION(OPENSSL, OPENSSL_VERSION_NUMBER)
  cargo:warning=      | ^~~~~~~
  exit status: 1

  --- stderr
  thread 'main' panicked at '
  Header expansion error:
  Error { kind: ToolExecError, message: "Command \"cc\" \"-O0\" \"-ffunction-sections\" \"-fdata-sections\" \"-fPIC\" \"-g\" \"-fno-omit-frame-pointer\" \"-m64\" \"-I\" \"/usr/include\" \"-Wall\" \"-Wextra\" \"-E\" \"build/expando.c\" with args \"cc\" did not execute successfully (status code exit status: 1)." }

  Failed to find OpenSSL development headers.

  You can try fixing this setting the `OPENSSL_DIR` environment variable
  pointing to your OpenSSL installation or installing OpenSSL headers package
  specific to your distribution:

      # On Ubuntu
      sudo apt-get install libssl-dev
      # On Arch Linux
      sudo pacman -S openssl
      # On Fedora
      sudo dnf install openssl-devel

If I export OPENSSL_DIR=/usr/include/openssl, it just complains that there's no lib sub-dir under that path:

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

Caused by:
  process didn't exit successfully: `<redacted-path>` (exit status: 101)
  --- stdout
  cargo:rustc-cfg=const_fn
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
  OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
  OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_DIR
  OPENSSL_DIR = /usr/include/openssl

  --- stderr
  thread 'main' panicked at 'OpenSSL library directory does not exist: /usr/include/openssl/lib', <redacted-home>/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.63/build/main.rs:66:9

I'm not sure what more I could be missing in this case, given the error messages.

@lowkeyop
Copy link

lowkeyop commented Jun 17, 2022 via email

@ghost-in-the-zsh
Copy link

I gave it a try with sudo apt remove -y pkg-config build-essential libssl-dev:amd64 librust-openssl-sys-dev:amd64 && sudo apt install -y pkg-config build-essential libssl-dev librust-openssl-sys-dev && sudo apt-mark auto pkg-config build-essential, but it didn't work. (I also tried unset OPENSSL_DIR afterwards, but no dice.)

@ghost-in-the-zsh
Copy link

I posted a solution for this issue here.

@Nas2020
Copy link

Nas2020 commented Jul 3, 2022

Works now, ran sudo apt install pkg-config

thank you. this worked for me

@rRaDuCaN
Copy link

rRaDuCaN commented Jul 7, 2022

@test482
Copy link

test482 commented Jul 20, 2022

I gave it a try with sudo apt remove -y pkg-config build-essential libssl-dev:amd64 librust-openssl-sys-dev:amd64 && sudo apt install -y pkg-config build-essential libssl-dev librust-openssl-sys-dev && sudo apt-mark auto pkg-config build-essential, but it didn't work. (I also tried unset OPENSSL_DIR afterwards, but no dice.)

It fix my problem on WSL2 Ubuntu 20.04 LTS, Thanks.

@serkanozturkpmp
Copy link

I was missing Make. I installed it on Ubuntu using sudo apt-get install build-essential

Thank you @WarSame it really helps

@Raduc4
Copy link

Raduc4 commented Sep 16, 2022

I installed perl

@lowkeyop
Copy link

lowkeyop commented Oct 11, 2022 via email

@porkstoners
Copy link

I'm using Ubuntu and the error message says:

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

So I installed it:

sudo apt install libssl-dev

And it is working now.

works for me, thanks

Worked for me as well, thanks

@gordug
Copy link

gordug commented Jun 24, 2023

I'm using Ubuntu and the error message says:

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

So I installed it:

sudo apt install libssl-dev

And it is working now.

Worked for me, thanks

@GuoMonth
Copy link

GuoMonth commented Aug 8, 2023

Works now, ran sudo apt install pkg-config

in dockerfile,add this and work:

# Install pkg-config to avoid error: "error: could not find native static library `openssl`" and OPENSSL_LIB_DIR , OPENSSL_INCLUDE_DIR , OPENSSL_DIR
RUN apt-get update \
    && apt-get install -y pkg-config \
    && apt install libssl-dev \
    && rm -rf /var/lib/apt/lists/*

@dnh4
Copy link

dnh4 commented Aug 30, 2023

I Followed the indtruction above I have that again!?
I am new in rust

sudo apt-get install pkg-config libssl-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
pkg-config is already the newest version (0.29.2-1ubuntu3).
libssl-dev is already the newest version (3.0.2-0ubuntu1.10).
0 upgraded, 0 newly installed, 0 to remove and 429 not upgraded.

In the Cargo.toml

[dependencies]
openssl = "0.10.57"
openssl-sys = "0.9.92"
reqwest = "0.11.20"
scraper = "0.17.1"
web-view = "0.7.3"

cargo build
   Compiling proc-macro2 v1.0.66
   Compiling unicode-ident v1.0.11
   Compiling pkg-config v0.3.27
   Compiling serde v1.0.188
   Compiling syn v1.0.109
   Compiling libc v0.2.147
   Compiling thiserror v1.0.47
   Compiling quote v1.0.33
   Compiling syn v2.0.29
   Compiling unicode-segmentation v1.10.1
   Compiling heck v0.3.3
   Compiling toml v0.5.11
   Compiling strum v0.18.0
   Compiling version-compare v0.0.10
   Compiling cfg-if v1.0.0
   Compiling siphasher v0.3.11
   Compiling getrandom v0.2.10
   Compiling autocfg v1.1.0
   Compiling rand_core v0.6.4
   Compiling cc v1.0.83
   Compiling ppv-lite86 v0.2.17
   Compiling rand_chacha v0.3.1
   Compiling rand v0.8.5
   Compiling once_cell v1.18.0
   Compiling phf_shared v0.10.0
   Compiling itoa v1.0.9
   Compiling vcpkg v0.2.15
   Compiling phf_generator v0.10.0
   Compiling pin-project-lite v0.2.13
   Compiling bytes v1.4.0
   Compiling thiserror-impl v1.0.47
   Compiling strum_macros v0.18.0
   Compiling openssl-sys v0.9.92
   Compiling futures-core v0.3.28
   Compiling phf_codegen v0.10.0
   Compiling smallvec v1.11.0
error: failed to run custom build command for `openssl-sys v0.9.92`

Caused by:
  process didn't exit successfully: `/home/dev/Documents/Github/First_rust/rust_tuto/target/debug/build/openssl-sys-b672fba3f4146689/build-script-main` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
  OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
  OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_DIR
  OPENSSL_DIR = /usr/lib/ssl

  --- stderr
  thread 'main' panicked at 'OpenSSL include directory does not exist: /usr/lib/ssl/include', /home/dev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-sys-0.9.92/build/main.rs:79:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

@merlindru
Copy link

I was missing Make. I installed it on Ubuntu using sudo apt-get install build-essential

Thank you!! This worked for me

@dnh4
Copy link

dnh4 commented Sep 22, 2023

I was missing Make. I installed it on Ubuntu using sudo apt-get install build-essential

Thank you!! This worked for me

How dit you do? Can you help.

I'm on a fresh Ubuntu 22.04 LTS install and I'm still running into this issue. (As far as I can recall, my old machine, which had started with 18.04 and upgraded its way to 22.04 never ran into this issue.) The following packages are automatically included in 22.04 already: pgk-config, build-essential. I manually installed the libssl-dev package and also tried with librust-openssl-dev, as suggested in a prior comment, but there was no difference.

$ cargo build
   Compiling openssl-sys v0.9.63
   Compiling http-body v0.4.1
   Compiling syn v1.0.89
   Compiling tokio v1.5.0
   Compiling proc-macro-error-attr v1.0.4
   Compiling idna v0.2.3
   Compiling num-integer v0.1.44
   Compiling regex v1.5.3
The following warnings were emitted during compilation:

warning: build/expando.c:4:24: error: pasting "RUST_VERSION_OPENSSL_" and "(" does not give a valid preprocessing token
warning:     4 | #define VERSION2(n, v) RUST_VERSION_##n##_##v
warning:       |                        ^~~~~~~~~~~~~
warning: build/expando.c:5:23: note: in expansion of macro ‘VERSION2’
warning:     5 | #define VERSION(n, v) VERSION2(n, v)
warning:       |                       ^~~~~~~~
warning: build/expando.c:10:1: note: in expansion of macro ‘VERSION’
warning:    10 | VERSION(OPENSSL, OPENSSL_VERSION_NUMBER)
warning:       | ^~~~~~~

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

Caused by:
  process didn't exit successfully: <redacted-path> (exit status: 101)
  --- stdout
  cargo:rustc-cfg=const_fn
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
  OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
  OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_DIR
  OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=OPENSSL_STATIC
  cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=SYSROOT
  cargo:rerun-if-env-changed=OPENSSL_STATIC
  cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rustc-link-lib=ssl
  cargo:rustc-link-lib=crypto
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=OPENSSL_STATIC
  cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  OPT_LEVEL = Some("0")
  TARGET = Some("x86_64-unknown-linux-gnu")
  HOST = Some("x86_64-unknown-linux-gnu")
  CC_x86_64-unknown-linux-gnu = None
  CC_x86_64_unknown_linux_gnu = None
  HOST_CC = None
  CC = None
  CFLAGS_x86_64-unknown-linux-gnu = None
  CFLAGS_x86_64_unknown_linux_gnu = None
  HOST_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-I" "/usr/include" "-Wall" "-Wextra" "-E" "build/expando.c"
  cargo:warning=build/expando.c:4:24: error: pasting "RUST_VERSION_OPENSSL_" and "(" does not give a valid preprocessing token
  cargo:warning=    4 | #define VERSION2(n, v) RUST_VERSION_##n##_##v
  cargo:warning=      |                        ^~~~~~~~~~~~~
  cargo:warning=build/expando.c:5:23: note: in expansion of macro ‘VERSION2’
  cargo:warning=    5 | #define VERSION(n, v) VERSION2(n, v)
  cargo:warning=      |                       ^~~~~~~~
  cargo:warning=build/expando.c:10:1: note: in expansion of macro ‘VERSION’
  cargo:warning=   10 | VERSION(OPENSSL, OPENSSL_VERSION_NUMBER)
  cargo:warning=      | ^~~~~~~
  exit status: 1

  --- stderr
  thread 'main' panicked at '
  Header expansion error:
  Error { kind: ToolExecError, message: "Command \"cc\" \"-O0\" \"-ffunction-sections\" \"-fdata-sections\" \"-fPIC\" \"-g\" \"-fno-omit-frame-pointer\" \"-m64\" \"-I\" \"/usr/include\" \"-Wall\" \"-Wextra\" \"-E\" \"build/expando.c\" with args \"cc\" did not execute successfully (status code exit status: 1)." }

  Failed to find OpenSSL development headers.

  You can try fixing this setting the `OPENSSL_DIR` environment variable
  pointing to your OpenSSL installation or installing OpenSSL headers package
  specific to your distribution:

      # On Ubuntu
      sudo apt-get install libssl-dev
      # On Arch Linux
      sudo pacman -S openssl
      # On Fedora
      sudo dnf install openssl-devel

If I export OPENSSL_DIR=/usr/include/openssl, it just complains that there's no lib sub-dir under that path:

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

Caused by:
  process didn't exit successfully: `<redacted-path>` (exit status: 101)
  --- stdout
  cargo:rustc-cfg=const_fn
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
  OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
  OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_DIR
  OPENSSL_DIR = /usr/include/openssl

  --- stderr
  thread 'main' panicked at 'OpenSSL library directory does not exist: /usr/include/openssl/lib', <redacted-home>/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.63/build/main.rs:66:9

I'm not sure what more I could be missing in this case, given the error messages.

The same to me @ghost-in-the-zsh did you fin the solution?

@daiyongxuan
Copy link

when I compile rust prj, I changed the dependecy of requesturl, and it works.
the dependency is as follows:

reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }

@bartvdbraak
Copy link

bartvdbraak commented Nov 6, 2023

I keep getting this error in my GitHub actions for building.

https://github.com/bartvdbraak/keyweave/actions/runs/6766774148/job/18388342200#step:6:419

error: failed to run custom build command for `openssl-sys v0.9.95`
Caused by:
  process didn't exit successfully: `/target/release/build/openssl-sys-ad90ed1184271933/build-script-main` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
  OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
  OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_DIR
  OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=OPENSSL_STATIC
  cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  run pkg_config fail: `PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" "pkg-config" "--libs" "--cflags" "openssl"` did not exit successfully: exit status: 1
  error: could not find system library 'openssl' required by the 'openssl-sys' crate
  --- stderr
  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
  No package 'openssl' found
  --- stderr
  thread 'main' panicked at /cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-sys-0.9.95/build/find_normal.rs:190:5:
  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-unknown-linux-gnu
  $TARGET = x86_64-unknown-linux-gnu
  openssl-sys = 0.9.95
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
+ rustup component list --toolchain stable-x86_64-unknown-linux-gnu
Error: The process 'cross' failed with exit code 101

I was able to resolve this by adding this in my cargo.toml file:

[target.'cfg(all(target_os = "linux", any(target_env = "musl", target_arch = "arm", target_arch = "aarch64")))'.dependencies]
openssl = { version = "0.10", features = ["vendored"] }

@HedgehogNSK
Copy link

I had to install librust-openssl-dev on Ubuntu Server 20.04:

sudo apt install librust-openssl-dev

I don't know how much people will read until this comment. But this answer helped me also with Ubuntu 22.04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests