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

openssl-sys doesn't automatically detect openssl after installing via vcpkg on Windows #2125

Open
eureka-cpu opened this issue Dec 12, 2023 · 2 comments · May be fixed by #2139
Open

openssl-sys doesn't automatically detect openssl after installing via vcpkg on Windows #2125

eureka-cpu opened this issue Dec 12, 2023 · 2 comments · May be fixed by #2139

Comments

@eureka-cpu
Copy link

eureka-cpu commented Dec 12, 2023

Hello, I'm not very familiar with development on Windows, and I'm trying to build a project that requires openssl-sys. I've installed openssl via vcpkg as described in the docs, but I'm getting this error. It's likely this is not a bug but rather the docs are a tad incomplete in getting the automatic detection route working. I've also tried installing the package manually and assigning the path with the OPENSSL_DIR environment variable, but openssl-sys claims that the lib directory given is insufficient. I've uninstalled that, but I'm happy to re-install and paste the error if that's the correct way to go about it. Any help is appreciated.

   Compiling openssl-sys v0.9.96
error: failed to run custom build command for `openssl-sys v0.9.96`

Caused by:
  process didn't exit successfully: `C:\Users\obrch\Code\versatus\target\debug\build\openssl-sys-789dd0cb3f81db9a\build-script-main` (exit code: 101)
  --- stdout
  cargo:rerun-if-env-changed=X86_64_PC_WINDOWS_MSVC_OPENSSL_LIB_DIR
  X86_64_PC_WINDOWS_MSVC_OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
  OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=X86_64_PC_WINDOWS_MSVC_OPENSSL_INCLUDE_DIR
  X86_64_PC_WINDOWS_MSVC_OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
  OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=X86_64_PC_WINDOWS_MSVC_OPENSSL_DIR
  X86_64_PC_WINDOWS_MSVC_OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_DIR
  OPENSSL_DIR unset
  note: vcpkg did not find openssl: Could not find library in Vcpkg tree package openssl is not installed for vcpkg triplet x64-windows-static-md

  --- stderr
  thread 'main' panicked at C:\Users\obrch\.cargo\registry\src\index.crates.io-6f17d22bba15001f\openssl-sys-0.9.96\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-pc-windows-msvc
  $TARGET = x86_64-pc-windows-msvc
  openssl-sys = 0.9.96


  It looks like you're compiling for MSVC but we couldn't detect an OpenSSL
  installation. If there isn't one installed then you can try the rust-openssl
  README for more information about how to download precompiled binaries of
  OpenSSL:

  https://github.com/sfackler/rust-openssl#windows
PS C:\Users\obrch\Code\vcpkg> .\vcpkg install openssl
warning: In the September 2023 release, the default triplet for vcpkg libraries changed from x86-windows to the detected host triplet (x64-windows). For the old behavior, add --triplet x86-windows . To suppress this message, add --triplet x64-windows .
Computing installation plan...
The following packages are already installed:
    openssl:x64-windows -> 3.1.4#1
openssl:x64-windows is already installed
Total install time: 74.2 us
The package openssl is compatible with built-in CMake targets:

    find_package(OpenSSL REQUIRED)
    target_link_libraries(main PRIVATE OpenSSL::SSL OpenSSL::Crypto)
@eureka-cpu
Copy link
Author

Also the #windows link just takes me to the GitHub repository, not any Windows specific help doc, it may be outdated as well.

@sfackler
Copy link
Owner

note: vcpkg did not find openssl: Could not find library in Vcpkg tree package openssl is not installed for vcpkg triplet x64-windows-static-md

openssl-sys looks for the statically linked target by default. See https://docs.rs/vcpkg/latest/vcpkg/#static-vs-dynamic-linking for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants