Manually set link.exe location

I have a new computer and I’m working towards getting rust set up. I was warned during the installation of rustup that I didn’t have the C++ build tools installed. After installing and reinstalling several times, I gave up and proceeded with the installation. Upon running cargo build, I’m greeted with this error

error: linker link.exe not found
|
= note: The system cannot find the file specified. (os error 2)

I searched my C:\Program Files (x86)\Microsoft Visual Studio directory and it is in fact there


I suspect Rust’s failure to find it is due to the fact that I’m running Visual Studio 2019 Preview rather than Release. I tried fishing around online for a solution but failed to find one. Is there a way to manually set the link.exe path when using rustc?

hello,

I think this might be helpful: https://doc.rust-lang.org/cargo/reference/config.html

It shows linker = ".." option

For example in root of my project there is .cargo/config:

[target.arm-linux-androideabi]
linker = "arm-linux-androideabi-gcc"

@oezgurmakkurt and @davemilter thx for your help! It worked but then I was greeted with missing dll errors. After some searching I discovered all I have to do is launch cargo/rustc through the “x64 Native Tools Command Prompt for VS 2019 Preview”, it even works without setting the linker! Thank you guys so much, would’ve taken forever on my own. :sweat_smile:

1 Like