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

Failure to find appropriate headers on Ubuntu 24.04 despite having libssl-dev installed #2217

Open
samuela opened this issue Apr 9, 2024 · 9 comments

Comments

@samuela
Copy link

samuela commented Apr 9, 2024

I'm currently seeing an error:

  cargo:warning=In file included from /usr/include/openssl/opensslv.h:109,
  cargo:warning=                 from build/expando.c:1:
  cargo:warning=/usr/include/openssl/macros.h:14:10: fatal error: openssl/opensslconf.h: No such file or directory
  cargo:warning=   14 | #include <openssl/opensslconf.h>
  cargo:warning=      |          ^~~~~~~~~~~~~~~~~~~~~~~
  cargo:warning=compilation terminated.

  --- stderr
  thread 'main' panicked at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-sys-0.9.101/build/main.rs:186:13:

  Header expansion error:
  Error { kind: ToolExecError, message: "Command \"cc\" \"-O0\" \"-ffunction-sections\" \"-fdata-sections\" \"-fPIC\" \"-gdwarf-4\" \"-fno-omit-frame-pointer\" \"-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
...

Full log available in this gist.

However I have pkg-config and libssl-dev installed and up to date:

root@6b49c5e222e1:/workspaces/sshenanigans# 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 (1.8.1-2).
libssl-dev is already the newest version (3.0.13-0ubuntu3).
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
root@6b49c5e222e1:/workspaces/sshenanigans# 

Inspecting /usr/include, I can see that /usr/include/openssl/ has 133 header files, all the usual suspects, and /usr/include/aarch64-linux-gnu/openssl/ contains two header files: configuration.h and opensslconf.h.

For reproducibility, I'm attempting to cargo build a rust project that depends on openssl-sys from within this Docker container:

FROM ubuntu:24.04
RUN apt-get update && apt-get install -y curl libssl-dev pkg-config
# See https://github.com/DeterminateSystems/nix-installer?tab=readme-ov-file#in-a-container.
RUN curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install linux --init none --no-confirm
ENV PATH="${PATH}:/nix/var/nix/profiles/default/bin"
RUN nix profile install nixpkgs#cargo nixpkgs#gcc
@samuela
Copy link
Author

samuela commented Apr 9, 2024

I'm also able to reproduce the same behavior on Ubuntu 22.04

@samuela
Copy link
Author

samuela commented Apr 9, 2024

Using cargo from a rustup installation works however...

@samuela
Copy link
Author

samuela commented Apr 9, 2024

Ok, using cargo from rustup, but gcc from nixpkgs (nix profile install nixpkgs#gcc instead of apt-get install build-essential) produces the error. So I suspect something in that cc` or its configuration is at fault...

@dlime
Copy link

dlime commented Jul 16, 2024

With Ubuntu 24 and libssl-dev installed, I have solved this problem by symlinking the missing files from /usr/include/x86_64-linux-gnu/ to /usr/include/openssl/

sudo ln -s /usr/include/x86_64-linux-gnu/openssl/opensslconf.h /usr/include/openssl/opensslconf.h
sudo ln -s /usr/include/x86_64-linux-gnu/openssl/configuration.h /usr/include/openssl/configuration.h

@lee-orr
Copy link

lee-orr commented Jul 19, 2024

This also happens when utilizing zig as a replacement for cc

@secnigma
Copy link

I've had the same issue while trying to build dog v0.1.0. The issue was solved by adding openssl as a dependency in the Cargo.toml file.

Line added under [dependencies]

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

After that try cargo build again.

Environment

OS: Debian GNU/Linux 12 (bookworm)
Kernel: 6.9.7-1~bpo12+1 (2024-07-03) x86_64 GNU/Linux
Cargo Version: 1.78.0
Rustc version: 1.78.0

Reference was taken from a Stackoverflow thread.

@0xn4utilus
Copy link

With Ubuntu 24 and libssl-dev installed, I have solved this problem by symlinking the missing files from /usr/include/x86_64-linux-gnu/ to /usr/include/openssl/

sudo ln -s /usr/include/x86_64-linux-gnu/openssl/opensslconf.h /usr/include/openssl/opensslconf.h
sudo ln -s /usr/include/x86_64-linux-gnu/openssl/configuration.h /usr/include/openssl/configuration.h

thanks man, this really helped

@HKMV
Copy link

HKMV commented Nov 29, 2024

With Ubuntu 24 and libssl-dev installed, I have solved this problem by symlinking the missing files from /usr/include/x86_64-linux-gnu/ to /usr/include/openssl/

sudo ln -s /usr/include/x86_64-linux-gnu/openssl/opensslconf.h /usr/include/openssl/opensslconf.h
sudo ln -s /usr/include/x86_64-linux-gnu/openssl/configuration.h /usr/include/openssl/configuration.h

Thank you, you have successfully solved my problem

@HeenaBansal20
Copy link

I am also facing the same issue on ubuntu22.04 and I added the symlink. But I am facing the same error for <openssl/opensslconf.h> but not for <opensslconf.h>

My include dir is set to /usr/include/openssl where all header files reside. I tried with include dir set to /usr/include so that cmake find in the path /usr/include/openssl directory but it also didn't help.
Any help will be appreciated.

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

7 participants