WeBankBlockchain / WeDPR-Lab-Core

Core libraries of WeDPR instant scenario-focused solutions for privacy-inspired business; WeDPR即时可用场景式隐私保护高效解决方案核心算法组件
Apache License 2.0
168 stars 34 forks source link

windows openssl compilation error #33

Open triplewz opened 3 years ago

triplewz commented 3 years ago

你好,请问这个能在windows下编译吗,我编译的时候出现这个问题是怎么回事呢?

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

Caused by:
  process didn't exit successfully: `D:\rust\WeDPR-Lab-Core\target\debug\build\openssl-sys-9907d4d9e796620a\build-script-main` (exit code: 101)
  --- stdout
  cargo:rustc-cfg=const_fn
  cargo:rerun-if-env-changed=X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR
  X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
  OPENSSL_NO_VENDOR unset
  running "perl" "./Configure" "--prefix=D:\\rust\\WeDPR-Lab-Core\\target\\debug\\build\\openssl-sys-d00d5dea42c1c716\\out\\openssl-build\\install" "no-dso" "no-ssl3" "no-unit-test" "no-comp" "no-zlib" "no-zlib-dynamic" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "no-engine" "no-asm" "VC-WIN64A"

  --- stderr
qyan-dev commented 3 years ago

It can be compiled on Windows, but you need to install openssl library first.

The easiest way is to install Strawberry Perl, which will include all the requried openssl dependences.

https://strawberryperl.com/

qyan-dev commented 3 years ago

It can be compiled on Windows, but you need to install openssl library first.

The easiest way is to install Strawberry Perl, which will include all the requried openssl dependences.

https://strawberryperl.com/

Some of features need openssl source code for cross compilation targeting other instruction set.

But for x86/x64, there is actually an easier way to install precompiled openssl from https://slproweb.com/products/Win32OpenSSL.html

  1. Please use the default install path.
  2. After installation, set system environment variable OPENSSL_DIR=C:\Program Files\OpenSSL-Win64

Then cargo build should work.

triplewz commented 3 years ago

I have installed OPENSSL, and set system environment variable. 微信截图_20210114144229 But it did't work.

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

Caused by:
  process didn't exit successfully: `C:\Users\rust\WeDPR-Lab-Core\target\debug\build\openssl-sys-9907d4d9e796620a\build-script-main` (exit code: 101)
  --- stdout
  cargo:rustc-cfg=const_fn
  cargo:rerun-if-env-changed=X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR
  X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
  OPENSSL_NO_VENDOR unset
  running "perl" "./Configure" "--prefix=C:\\Users\\rust\\WeDPR-Lab-Core\\target\\debug\\build\\openssl-sys-d00d5dea42c1c716\\out\\openssl-build\\install" "no-dso" "no-ssl3" "no-unit-test" "no-comp" "no-zlib" "no-zlib-dynamic" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "no-engine" "no-asm" "VC-WIN64A"

  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "系统找不到指定的文件。" }', C:\Users\.cargo\registry\src\mirrors.sjtug.sjtu.edu.cn-7a04d2510079875b\openssl-src-111.13.0+1.1.1i\src\lib.rs:413:39
qyan-dev commented 3 years ago

Strange. Use openssl on Windows is complex :-)

Could you try to remove OPENSSL_INCLUDE_DIR and OPENSSL_LIB_DIR?

I only set OPENSSL_DIR=C:\Program Files\OpenSSL-Win64 on my computer.

If it is still not working , just try installing the Strawberry Perl.

https://strawberryperl.com/

triplewz commented 3 years ago

I reinstalled OPENSSL, and built it successfully. Thanks!

qyan-dev commented 3 years ago

Cool. Good to know this :-)