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

Could not find openssl on build (fix included) #122

Open
sem-hub opened this issue Oct 18, 2023 · 2 comments
Open

Could not find openssl on build (fix included) #122

sem-hub opened this issue Oct 18, 2023 · 2 comments

Comments

@sem-hub
Copy link

sem-hub commented Oct 18, 2023

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

@kaderud
Copy link

kaderud commented Jan 15, 2024

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

@johnchristopher
Copy link

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

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

3 participants