请教一下FFI Rust绑定C库snappy, 调用绑定库 会 出现编译出错. 使用的工具链是 stable-x86_64-pc-windows-msvc, 系统是win10
百度说需要安装vs-buildtools, 我已经安装了2017,2019都安装了 还是报错
报错信息如下, 请问怎么搞?或者给相关FFI教程详细连接也没有问题
error: linking with link.exe
failed: exit code: 1181
|
= note: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\link.exe" "/NOLOGO" "d:\wp\tc\target\debug\deps\tc.10p401rj126a3et6.rcgu.o" "d:\wp\tc\target\debug\deps\tc.1sc08oc3ch9f69b4.rcgu.o" "d:\wp\tc\target\debug\deps\tc.2lxl0lxb5jfr65jz.rcgu.o" "d:\wp\tc\target\debug\deps\tc.2n965mn21gx205gx.rcgu.o" "d:\wp\tc\target\debug\deps\tc.2qkmoiokqhxhk4s4.rcgu.o" "d:\wp\tc\target\debug\deps\tc.3mp65lwdq0t5zoc0.rcgu.o" "d:\wp\tc\target\debug\deps\tc.44manjekxa94y1d9.rcgu.o" "d:\wp\tc\target\debug\deps\tc.4e1c983d7m7uteq4.rcgu.o" "d:\wp\tc\target\debug\deps\tc.n4d0ndcghjx5xi9.rcgu.o" "d:\wp\tc\target\debug\deps\tc.eg8fdv29av94hqb.rcgu.o" "/LIBPATH:d:\wp\tc\target\debug\deps" "/LIBPATH:C:\Users\Administrator\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib" "D:\wp\tc\target\debug\deps\libtc-dae873ddd7d9a6b2.rlib" "D:\wp\tc\target\debug\deps\liblibc-ba8056213dac10e1.rlib" "C:\Users\Administrator\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libstd-9505d954cc550ca4.rlib" "C:\Users\Administrator\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libpanic_unwind-4368ec34df66b968.rlib" "C:\Users\Administrator\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\librustc_demangle-c4e960482b87deda.rlib" "C:\Users\Administrator\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libstd_detect-3e30157661c6e929.rlib" "C:\Users\Administrator\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libhashbrown-441bbf33311d8f21.rlib" "C:\Users\Administrator\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\librustc_std_workspace_alloc-a65adc14aa7ec78a.rlib" "C:\Users\Administrator\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libunwind-754bada3b2f76f43.rlib" "C:\Users\Administrator\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libcfg_if-bbc7454d63bcee48.rlib" "C:\Users\Administrator\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\liblibc-083a8721e26e7568.rlib" "C:\Users\Administrator\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\liballoc-fc82f5be4815a343.rlib" "C:\Users\Administrator\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\librustc_std_workspace_core-14f675cf009ff7ec.rlib" "C:\Users\Administrator\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libcore-39142ba17f25ae37.rlib" "C:\Users\Administrator\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libcompiler_builtins-1a5802a39db22341.rlib" "snappy.lib" "kernel32.lib" "ws2_32.lib" "bcrypt.lib" "advapi32.lib" "userenv.lib" "kernel32.lib" "msvcrt.lib" "/NXCOMPAT" "/LIBPATH:C:\Users\Administrator\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib" "/OUT:d:\wp\tc\target\debug\deps\tc.exe" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\Users\Administrator\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\etc\intrinsic.natvis" "/NATVIS:C:\Users\Administrator\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\etc\liballoc.natvis" "/NATVIS:C:\Users\Administrator\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\etc\libcore.natvis" "/NATVIS:C:\Users\Administrator\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\etc\libstd.natvis"
= 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\xb0snappy.lib\xa1\xb1\r\n
评论区
写评论提示得很清楚了
https://github.com/jeffbelgum/rust-snappy
大神, 我的rust是按rust官网的安装的.
我说的问题是, 按着您之前的文章Rust FFI 编程 - 手动绑定 C 库入门 01
绑定的snappy-rs 的lib库编译成功了, 但是到了调用这个绑定库时报错, 意思大概是链接器找不到snappy.lib动态库.
我在网上下载了snappy32.lib, 分包放在C:\Windows\SysWOW64 或者 C:\Windows\System32 执行cargo build 都失败了
以下为代码,有部分缩略
至此编译成功.
到了调用就失败了
--
👇
Mike Tang: 按官方说明搞,不要百度这里那里的。
https://forge.rust-lang.org/infra/other-installation-methods.html
按官方说明搞,不要百度这里那里的。
https://forge.rust-lang.org/infra/other-installation-methods.html