開始學習rust,安裝好rust的環境,開始從hello world開始,結果用在win10環境下,使用vs code或cmd窗口編譯rust報錯:
PS E:\study_codes\rust-demo\chart01> rustc hello.rs
error: linker `link.exe` not found|= note: program not foundnote: the msvc targets depend on the msvc linker but `link.exe` was not foundnote: please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option.note: VS Code is a different product, and is not sufficient.error: aborting due to 1 previous error
vs code或cmd窗口中運行以下命令即可解決:
rustup uninstall toolchain stable-x86_64-pc-windows-msvc
rustup toolchain install stable-x86_64-pc-windows-gnu
rustup default stable-x86_64-pc-windows-gnu
運行rust編譯命令:
rustc hello.rs
.\hello.exe
生成一個hello.exe文件
運行結果:
hello world
Have fun learning about rust!