|
| 1 | +# MSVC prerequistes |
| 2 | + |
| 3 | +To compile programs into an exe file, Rust requires a linker, libraries and Windows API import libraries. |
| 4 | +For `msvc` targets these can be acquired through Visual Studio. |
| 5 | + |
| 6 | +## Automatic install |
| 7 | + |
| 8 | +If you don't have Visual Studio already installed then [rustup-init] will offer to automatically install the prerequisites. |
| 9 | +Doing so means you can skip the rest of this page. |
| 10 | +However, it installs Visual Studio Community edition which may not be appropriate for all users. |
| 11 | + |
| 12 | +## Manual install |
| 13 | + |
| 14 | +[Download Visual Studio][vs downloads]. |
| 15 | +Rust supports Visual Studio 2013 and later but it is recommended that you use the latest version (currently 2022) for new projects. |
| 16 | +You can opt to download only the Build Tools for Visual Studio, which does not include the IDE. |
| 17 | +However this requires you already have a license to the Community, Professional or Enterprise edition. |
| 18 | + |
| 19 | +Once you've downloaded and started the installer, the easiest way to get everything installed is to select "Desktop Development with C++". |
| 20 | +This will include the necessary components. |
| 21 | +On the "Language Packs" tab, make sure the English language pack is installed in addition to your preferred language. |
| 22 | + |
| 23 | +If you want more details on the installation process or want to further customize the install then follow the walkthrough below. |
| 24 | +Otherwise complete the Visual Studio install and continue with installing Rust. |
| 25 | + |
| 26 | +## Walkthrough: Installing Visual Studio 2022 |
| 27 | + |
| 28 | +This walkthrough uses the Community edition of Visual Studio but the Professional, Enterprise and the Build Tools all work the same way. |
| 29 | + |
| 30 | +The installer will start by linking to the [license][vs licences] and for your edition of Visual Studio and then preparing the installer. |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | +Once this finishes, you can then select the components to be installed. |
| 36 | +Here we use the "Workload" tab to select the "Desktop Development with C++" workload. |
| 37 | +This will includes all needed components for Rust: |
| 38 | + |
| 39 | + |
| 40 | +### Installing only the required components (optional) |
| 41 | + |
| 42 | +If you'd like a more minimal install (and won't doing C++ development) then you can use the "Individual Components" tab to select just the essentials, which are: |
| 43 | + |
| 44 | +* MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest) |
| 45 | +* Windows 11 SDK (10.0.22621.0) |
| 46 | + |
| 47 | +Note that the specific version of the Windows SDK doesn't matter for pure Rust code but if using C++ as well you'll likely want either the latest or whichever version is required by the C++ project (or both). |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +### Completing the install |
| 53 | + |
| 54 | +After choosing the components, switch to the "Language Packs" tab and add the English language pack in addition to your preferred language. |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | +Finally click the install button and wait for everything to be installed. |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | +Once finished, you can continue on to installing Rust. |
| 63 | + |
| 64 | +[rustup-init]: https://rustup.rs |
| 65 | +[vs downloads]: https://visualstudio.microsoft.com/downloads/ |
| 66 | +[vs licences]: https://visualstudio.microsoft.com/license-terms/ |
0 commit comments