dog icon indicating copy to clipboard operation
dog copied to clipboard

Could not find openssl on build (fix included)

Open sem-hub opened this issue 2 years ago • 3 comments

$ git rev-parse --short HEAD 721440b $ rustc --version rustc 1.73.0 (cc66ad468 2023-10-03) $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.3 LTS Release: 22.04 Codename: jammy $ rustc --print cfg debug_assertions panic="unwind" target_arch="x86_64" target_endian="little" target_env="gnu" target_family="unix" target_feature="fxsr" target_feature="sse" target_feature="sse2" target_has_atomic="16" target_has_atomic="32" target_has_atomic="64" target_has_atomic="8" target_has_atomic="ptr" target_os="linux" target_pointer_width="64" target_vendor="unknown" unix $ dpkg -l libssl-dev Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-================-=================-============-================================================ ii libssl-dev:amd64 3.0.2-0ubuntu1.10 amd64 Secure Sockets Layer toolkit - development files $ cargo build --release ... running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-march=x86-64" "-mtune=generic" "-O2" "-pipe" "-fno-plt" "-fexceptions" "-Wp,-D_FORTIFY_SOURCE=2" "-Wformat" "-Werror=format-security" "-fstack-clash-protection" "-fcf-protection" "-I" "/usr/include" "-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" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-march=x86-64" "-mtune=generic" "-O2" "-pipe" "-fno-plt" "-fexceptions" "-Wp,-D_FORTIFY_SOURCE=2" "-Wformat" "-Werror=format-security" "-fstack-clash-protection" "-fcf-protection" "-I" "/usr/include" "-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

I could easily fix it with adding 'openssl = { version = "0.10", features = ["vendored"] }' in Cargo.toml in [dependencies] target.

sem-hub avatar Oct 18 '23 14:10 sem-hub

Can confirm this fix also works on Linux Mint 21.3 (virginia) , it builds the source successfully.

kaderud avatar Jan 15 '24 19:01 kaderud

Can confirm this works on debian 12/bookworm:

  1. install libssl-dev with apt-install libssl-dev
  2. modify Cargo.toml by adding openssl = { version = "0.10", features = ["vendored"] } under [dependencies] section
  3. set OPENSSL_DIR env variable to /usr/lib/x86_64-linux-gnu
  4. finally run cargo build --release

johnchristopher avatar Mar 24 '24 07:03 johnchristopher