windows - `cargo build` 失败并出现链接错误 "link.exe failed: exit code: 325595"

标签 windows linker rust

我有一个 Rust 项目,可以在 Linux、macOS 和 Windows 10 上正常编译。

我今天使用 Visual Studio Installer 在我的 Windows 7 计算机上安装了以下各个组件:

  • VC++ 2015.3 v14.00 (v140) 桌面工具集
    • Windows 通用 CRT SDK(依赖项)
    • Windows 8.1 SDK(依赖项)

之后,我使用来自 official website 的全新 rustup-init.exe 安装了 Rust .

当我在 Windows 7 计算机上的 Rust 项目上运行 cargo build 时,它失败并显示以下消息:

error: linking with `C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\link.exe\` failed: exit code: 325595.

在我的 Windows 10 计算机上单独运行 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\link.exe 不带任何参数会产生一些“帮助"信息,但在我的 Windows 7 计算机上,我得到一个包含错误消息的窗口:

The application was unable to start correctly (0xc000007b).  Click Ok to close the application.

我的 Google-Fu 没有找到任何有用的信息。我试过:

  • sfc/scannow
  • 确保 System32 没有 32 位 DLL
  • 确保 SysWOW64 没有 64 位 DLL

最佳答案

更改默认链接器可解决此问题。我的系统是 64 位系统,但链接器指向 32 位系统。

rust中也提到了这个book

 rustup default stable-x86_64-pc-windows-gnu

阅读this有关为什么会发生这种情况的更多解释。

默认情况下,配置选择它用于 32 位,因此运行上面给出的命令会将链接器切换为 64 位。

关于windows - `cargo build` 失败并出现链接错误 "link.exe failed: exit code: 325595",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50337099/

相关文章:

windows - 网络共享文件夹上的 GIT 存储库中的并发性

java - 批处理文件如何接受 Java 的参数?

c++ - 如何在 C++ 中将 CHAR 变量复制到 WCHAR 变量

iphone - iPhone-XCode 4链接器错误,没有方法调用或对象使用

c++ - glViewport undefined reference

c - 嵌入式 ARM 和 C 运行时

boost - 线程静态编译示例

pointers - 将 Option<&mut T> 转换为 *mut T

rust - String,&str,Vec <u8>和&[u8]的惯用转换

rust - 为什么我不能在 QEMU 中启动自定义内核?