1、添加i686-pc-windows-msvc
target
rustup target add i686-pc-windows-msvc
2、编译目标文件
cargo build --target=i686-pc-windows-msvc
如果编译成功,那么什么事也没了。 如果出现这样的错误:
error: linker `i686-pc-windows-msvc` not found
|
= note: 系统找不到指定的文件。 (os error 2)
note: the msvc targets depend on the msvc linker but `link.exe` was not found
note: please ensure that VS 2013, VS 2015, VS 2017 or VS 2019 was installed with the Visual C++ option
error: aborting due to previous error
应该是找不到对应target
的link.exe
文件,需要在工程根目录下编写.cargo/config
文件,加入以下内容:
[target.i686-pc-windows-msvc]
linker = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.24.28314\\bin\\Hostx64\\x86\\link.exe"
这里特别需要注意linker
指向的link.exe
文件,一定要指向x86的,跟你target
相对应。