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

能否考虑sslocal支持下windows #89

Closed
limitee opened this issue Dec 7, 2017 · 21 comments
Closed

能否考虑sslocal支持下windows #89

limitee opened this issue Dec 7, 2017 · 21 comments

Comments

@limitee
Copy link

limitee commented Dec 7, 2017

No description provided.

@zonyitoo
Copy link
Collaborator

zonyitoo commented Dec 7, 2017

AppVeyor上可以编译。
把你遇到的问题详细说下

@limitee
Copy link
Author

limitee commented Dec 7, 2017

我使用的win10,1.22.1,stable,gnu,在cygwin下编译的,错误信息

SODIUM_BUILD_STATIC=yes cargo build --release
error: failed to run custom build command for `libsodium-ffi v0.1.9`
process didn't exit successfully: `C:\cygwin64\home\limit\workspace\csdn\shadowsocks-rust\target\debug\build\libsodium-ffi-3806734660f76369\build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=SODIUM_LIB_DIR
cargo:rerun-if-env-changed=SODIUM_STATIC
cargo:rerun-if-env-changed=SODIUM_BUILD_STATIC
running: "sh" "-c" "C:\\Users\\limit\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\libsodium-ffi-0.1.9\\libsodium\\autogen.sh"

--- stderr
sh: C:Userslimit.cargoregistrysrcgithub.com-1ecc6299db9ec823libsodium-ffi-0.1.9libsodiumautogen.sh: command not found
thread 'main' panicked at 'assertion failed: cmd.stdout(Stdio::inherit()).stderr(Stdio::inherit()).status().unwrap().success()', C:\Users\limit\.cargo\registry\src\github.com-1ecc6299db9ec823\libsodium-ffi-0.1.9\build.rs:93:4
note: Run with `RUST_BACKTRACE=1` for a backtrace.

@zonyitoo
Copy link
Collaborator

zonyitoo commented Dec 7, 2017

libsodium-ffiv0.1.9无法在Windows下编译。

目前我还在测试。你可以这样试一下:

修改Cargo.toml

[dependencies]
libsodium-ffi = { git = "https://github.com/zonyitoo/libsodium-ffi", optional = true }

再执行

SODIUM_BUILD_STATIC=yes cargo build --release

若能编过,我发布一下libsodium-ffi版本就可以了。我手上没有Windows机器,无法调试。

@zonyitoo
Copy link
Collaborator

zonyitoo commented Dec 7, 2017

当然,如果你用的加密方式不涉及libsodium的话,可以绕过它:

cargo build --release --no-default-features

@zonyitoo
Copy link
Collaborator

zonyitoo commented Dec 7, 2017

另外,如果用 msvc ABI的话,目前 AppVeyor 上已经确定可以编译通过的。

@limitee
Copy link
Author

limitee commented Dec 7, 2017

谢谢大神,我都尝试一下

@limitee
Copy link
Author

limitee commented Dec 7, 2017

gnu版本libsodium还是编译不过,msvc版本遇到新的问题,openssl,需要手动安装,能否用rust-crypto代替openssl呢?

@zonyitoo
Copy link
Collaborator

zonyitoo commented Dec 7, 2017

rust-crypto 已经一年多没有更新,已经废弃。

@zonyitoo
Copy link
Collaborator

zonyitoo commented Dec 7, 2017

openssl安装参考 https://github.com/shadowsocks/shadowsocks-rust/blob/master/appveyor.yml ,没有什么难度

@limitee
Copy link
Author

limitee commented Dec 13, 2017

编译都通过了,但是最后链接的时候,出现错误
···
= note: Non-UTF-8 output: LINK : fatal error LNK1181: \xce\xde\xb7\xa8\xb4\xf2\xbf\xaa\xca\xe4\xc8\xeb\xce\xc4\xbc\xfe\xa1\xb0sodium.lib\xa1\xb1\r\n
···

@zonyitoo
Copy link
Collaborator

zonyitoo commented Dec 13, 2017

\xce\xde\xb7\xa8\xb4\xf2\xbf\xaa\xca\xe4\xc8\xeb\xce\xc4\xbc\xfe\xa1\xb0sodium.lib\xa1\xb1

其实就是GBK编码的

无法打开输入文件“sodium.lib”

没见过这种问题……我也不知道怎么解决……AppVeyor上link没有报任何错误啊……

要不直接加--no-default-features,不要Link libsodium

@limitee
Copy link
Author

limitee commented Dec 14, 2017

能不能用
https://github.com/maidsafe/rust_sodium
代替一下,这个我试了一下,测试用例很全,而且不需要额外的设置。

@zonyitoo
Copy link
Collaborator

zonyitoo commented Dec 14, 2017

欢迎提PR

libsodium-ffi上,我借用了rust_sodium的Windows部分的代码。你试试看? @limitee

[dependencies]
libsodium-ffi = { git = "https://github.com/zonyitoo/libsodium-ffi", optional = true }

不能直接使用 rust_sodium ,它没有我们需要的 *_xor_ic 函数。

@zonyitoo
Copy link
Collaborator

https://ci.appveyor.com/project/zonyitoo/libsodium-ffi

AppVeyor上编译都没问题

@quininer
Copy link
Contributor

quininer commented Dec 16, 2017

只是需要 chacha20salsa20 的話,可以考慮下我這幾日包裝的 rust-hacl-star

@zonyitoo
Copy link
Collaborator

看了一下这个库相对比较小一些。看取舍了,我还是更倾向于使用更多人用的libsodium

@nlzy
Copy link

nlzy commented Jan 6, 2018

Windows 8.1, Rust 1.23.0 (x86_64-pc-windows-gnu),编译没问题。

环境变量:
OPENSSL_STATIC = yes
SODIUM_BUILD_STATIC = yes

用 MSYS2 安装 mingw-w64-x86_64-pkg-configmingw-w64-x64 mingw-w64-x86_64-openssl
然后在 PATH 中添加 X:\path_to_msys2\mingw64\bin

cmd 运行 cargo install shadowsocks-rust

@lqf96
Copy link

lqf96 commented Jan 18, 2018

似乎rust不支持在cygwin下编译吧,官方应该只支持mingw

@Matrix-Zhang
Copy link

我刚提交了PR,使用VCPKG安装libsodium, RUSTC使用msvc的target,就直接可以编译了

@zonyitoo
Copy link
Collaborator

zonyitoo commented Feb 9, 2020

NEWS: 目前libsodium可以用libsodium-sys自带的预编译lib,可以不用输入任何东西即可完成编译。只需要下载OpenSSL安装即可。编译过程可参考此脚本(in PowerShell)

# Check compile target, 32bits or 64bits
# This requires `rustc` in `$PATH`
$TargetTriple = (rustc -Vv | Select-String -Pattern "host: (.*)" | foreach {$_.Matches.Value}).split()[-1]
if ($TargetTriple.StartsWith("x86_64-")) {
    $OpenSSLBits = "64"
} else {
    $OpenSSLBits = "32"
}
$OpenSSLVersion = "1_1_1d"
$OpenSSLFileName = "Win${OpenSSLBits}OpenSSL-${OpenSSLVersion}.exe"

# Download OpenSSL release package to the current directory
$ProgressPreference = "SilentlyContinue"
Invoke-WebRequest -Uri "http://slproweb.com/download/${OpenSSLFileName}" -OutFile "${OpenSSLFileName}"

# Install it to C:\OpenSSL
Start-Process "${OpenSSLFileName}" -ArgumentList "/SILENT /VERYSILENT /SP- /SUPPRESSMSGBOXES /DIR=C:\OpenSSL" -Wait

# Build shadowsocks-rust's release
cargo build --release --features "miscreant"

@zonyitoo
Copy link
Collaborator

zonyitoo commented Feb 9, 2020

Discussion merged to #102 .

@zonyitoo zonyitoo closed this as completed Feb 9, 2020
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

6 participants