[Solved] Compile with openSSL error

I’m trying to build a rust library that uses the openssl-sys v0.9.40 crate.

The error I get is this:

error: failed to run custom build command for openssl-sys v0.9.40
process didn’t exit successfully: /home/matt/src/work/indy-sdk/libindy/target/debug/build/openssl-sys-818d5fb1c5b59f00/build-script-main (exit code: 101)
— stdout

— stderr
thread ‘main’ panicked at ‘OpenSSL library directory does not exist: lib’, /home/matt/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.40/build/main.rs:60:9
note: Run with RUST_BACKTRACE=1 for a backtrace.

I’m pretty sure I have ssl installed correctly, but it is possible I do not.

The environment variables OPENSSL_DIR and OPENSSL_LIB_DIR are not set. I don’t know what to set them to.


I ended up solving this after thinking about it a different way. I used apt-file list libssl-dev to find location of the openssl header files (which I already had but it confirms I was right) and libraries (.a & .so) files. I was able to set OPENSSL_LIB_DIR. And build worked.

1 Like

Another alternative is to use ishitatsuyuki’s 0.9.x branch. See his rejected pull request.

openssl = { git = "https://github.com/ishitatsuyuki/rust-openssl", branch = "0.9.x" }
1 Like

I also had to set OPENSSL_INCLUDE_DIR to /usr/include/ssl in addition to setting OPENSSL_LIB_DIR.