sfackler / rust-openssl

OpenSSL bindings for Rust
1.39k stars 743 forks source link

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

Closed karasjoh000 closed 5 years ago

karasjoh000 commented 5 years ago

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 commented 5 years ago

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

1.1.0g-2ubuntu4.1

sfackler commented 5 years ago

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

karasjoh000 commented 5 years ago

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 commented 5 years ago

so how do I configure pkg-config

karasjoh000 commented 5 years ago

Works now, ran sudo apt install pkg-config

agryaznov commented 5 years ago

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 commented 5 years ago

Works now, ran sudo apt install pkg-config

Thank you very much. from Korea.

lechatthecat commented 4 years ago

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.

ashWhiteHat commented 4 years ago

I fix this problem to add.

Cargo.toml

[dependencies]
openssl = { version = "0.10", features = ["vendored"] }
LeonidKrutovsky commented 4 years ago

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 commented 4 years ago

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 commented 3 years ago

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 commented 3 years ago

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

LeoniePhiline commented 3 years ago

For Googlers:

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

benniebendiksen commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

Im on windows btw );;;

lowkeyop commented 2 years ago

I recognized that operating on pure Windows wasn't very effective. I leveraged Window's WSL (Window's Subsystem Linux). I downloaded everything to the WSL Ubuntu environment and compiled it there. I still had VSCode. There's a plugin called something like Remote Server which allows you to access the directories and files in your WSL from your host WIndows environment.

Try downloading and running the code in the Ubuntu WSL on Windows. I ran into way less issues. You'll also have to run the linux/ubuntu equivalent of the commands in there as well. But there's documentation for that.

Cordell

On Fri, Dec 17, 2021 at 6:59 AM Borregopornz @.***> wrote:

Im on windows btw );;;

— Reply to this email directly, view it on GitHub https://github.com/sfackler/rust-openssl/issues/1021#issuecomment-996668622, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFAC7UVNFJTR4VP5E2PFE4LURMQ3FANCNFSM4GGFMJCQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

QuillChain commented 2 years ago

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.

It's working

lowkeyop commented 2 years ago

Correct, that's the same thing I had to do. Well done!

On Fri, Dec 17, 2021 at 2:13 PM Quill Chain @.***> wrote:

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.

It's working

— Reply to this email directly, view it on GitHub https://github.com/sfackler/rust-openssl/issues/1021#issuecomment-996973246, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFAC7UXIM3COBT7EP3FANDLURODWFANCNFSM4GGFMJCQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

z16166 commented 2 years ago

Im on windows btw );;;

install Perl first.

riteshkumargiitian commented 2 years ago

Im on windows btw );;;

For windows users :) (1). what worked for me was installing "openssl" package with choco:

choco install openssl

(2). then set its path to the variable:

set OPENSSL_DIR="C:\Program Files\OpenSSL-Win64"

hope that works for you too ...

rezazarchi commented 2 years ago

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

It won't install on Ubuntu 20.04. It shows error that couldn't find them.

surphury commented 2 years ago

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

it has worked for me as well on Linux mint... Thank you!

WarSame commented 2 years ago

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

spdrman commented 2 years ago

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.

This worked for me on Debian 11... thanks!

TheWeirdDev commented 2 years ago

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

sudo apt install librust-openssl-dev

HsiangSun commented 2 years ago

我正在使用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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

Try uninstalling those packages and reinstalling them. Or maybe even an just a sudo apt-get upgrade && sudo apt-get update -y. Then try again. I believe I ran into issues once with one of the packages fighting to install different versions of the same dependencies. But the commands mentioned earlier should install everything you need. I hope this suggestion helps.

On Thu, Jun 16, 2022 at 7:51 PM ghost-in-the-zsh @.***> wrote:

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_VERSIONOPENSSL" and "(" does not give a valid preprocessing token

warning: 4 | #define VERSION2(n, v) RUSTVERSION##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: (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_VERSIONOPENSSL" and "(" does not give a valid preprocessing token

cargo:warning= 4 | #define VERSION2(n, v) RUSTVERSION##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', /.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.

— Reply to this email directly, view it on GitHub https://github.com/sfackler/rust-openssl/issues/1021#issuecomment-1158287720, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFAC7UVSDLSC3IGCQ72ZFYLVPO4WNANCNFSM4GGFMJCQ . You are receiving this because you commented.Message ID: @.***>

ghost-in-the-zsh commented 2 years ago

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 commented 2 years ago

I posted a solution for this issue here.

Nas2020 commented 2 years ago

Works now, ran sudo apt install pkg-config

thank you. this worked for me

rRaDuCaN commented 2 years ago

for Windows users follow this link: https://stackoverflow.com/questions/55912871/how-to-work-with-openssl-for-rust-within-a-windows-development-environment

test482 commented 2 years ago

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 commented 2 years ago

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

Thank you @WarSame it really helps

Raduc4 commented 2 years ago

I installed perl

lowkeyop commented 2 years ago

I've also made a script for installing Rust on Ubuntu. Here's the source code for my script:

!/bin/bashcurl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf |

shecho "Rust Installation is complete. Now installing a C Compiler (gcc)"sudo apt install build-essential -ysudo apt-get install manpages-devecho "Verifying gcc succesfully installed..."gcc --versionecho "If text containing 'gcc' with OS and version numbers, installation was successful!"echo "You must restart your terminal for Rust installation to complete and take effect"sudo reboot -h nowecho "In case you\'re working with WSL (Windows Subsystem Linux), a reboot will not work. Will now exit the console. Start WSL back up after WSL is exited"sleep 3exit

I believe I made it for Windows Subsystem Linux, but should also work on a desktop version or even server version of Ubuntu

On Thu, Jun 16, 2022 at 8:21 PM ghost-in-the-zsh @.***> wrote:

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.)

— Reply to this email directly, view it on GitHub https://github.com/sfackler/rust-openssl/issues/1021#issuecomment-1158322661, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFAC7UULEP2CHLUXFSSJ4F3VPPAHHANCNFSM4GGFMJCQ . You are receiving this because you commented.Message ID: @.***>

porkstoners commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

Thank you!! This worked for me

dnh4 commented 1 year ago

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 commented 1 year ago

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 commented 11 months ago

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 commented 9 months ago

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