我正在尝试在 Windows 上编译 Rust 程序,但我收到此错误消息:
Compiling openssl-sys v0.6.4
failed to run custom build command for `openssl-sys v0.6.4`
[...]
failed to execute command: The system couldn't find the specified file. (os error 2)
Is `gcc` not installed? (see https://github.com/alexcrichton/gcc-rs#windows-notes for help)
--- stderr
thread '<main>' panicked at 'explicit panic', C:\Users\User\.cargo\registry\src\github.com-0a35038f75765ae4\gcc-0.3.12\src\lib.rs:510
Cargo 编译所有其他包都没有问题,但它无法编译 openssl 包。
我搜索了有关此特定错误的帮助并找到了 github issue for hyperium .第一个答案引用了 openssl building guide for Windows .
我不明白我必须如何在 Windows 中构建 openssl。我安装了 MinGW 并将 bin 路径添加到全局 PATH
变量中,因此可以访问 gcc,但这并没有解决错误。
我使用 Rust 1.2 和 Cargo 0.4.0。 My project是 Telegram API 包装器的示例。
最佳答案
1) 下载ssl
Installs Win32 OpenSSL v1.0.2d
在这里安装:C:\OpenSSL-Win32,C:\OpenSSL-Win32\include,C:\OpenSSL-Win32\lib
2) 安装MinGW,并添加系统env路径,,C:\MinGW\bin,重要,MinGW的安装路径包含char 'MinGW '
3) cmd 运行 env OPENSSLIBDIR=C:/OpenSSL-Win32/lib OPENSSLINCLUDEDIR=C:/OpenSSL-Win32/include cargo build
关于windows - 在 Windows 上构建 openssl-sys crate 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31896165/