Note Building Rust Before 0.8 on Windows Systems - vadimcn/rust GitHub Wiki
Please note that this is an in-progress and temporary guide only intended for versions of Rust before 0.8 on Windows systems.
This temporary guide will cover building Rust < 0.8 on a Windows system through MSYS & MinGW using gcc 4.8 .
NOTE
- Rust requires gcc < 4.6 to build, but recently mingw has upgraded whole system and it is currently not easy to match package versions. This guide directly uses gcc 4.8.
- Latest mingw w32api package (4.0.0-1) contains some bugs. See "Patches" section below for instruction.
- There are some abi change between gcc 4.6 and 4.8, and some tests are known to fail due to this. (https://github.com/mozilla/rust/issues/9205)
MSYS & MinGW Installation
- Download the MinGW installer:
- Run the
mingw-get-setupinstaller.
- For simplicity use the default path of
C:\MinGW, pretty please. - I like to install for all users.
- Run with Administrator privileges if possible.
- Make sure MinGW is on your system path.
;C:\MinGW\binfor example should be appended to the PATH environment variable, similar to these instructions: http://stackoverflow.com/a/6318188/458550 .- Be careful not to disturb the existing entries.
- It is pretty handy to create a shortcut on your desktop to
C:\MinGW\msys\1.0\msys.bat
MSYS & MinGW Packages
We have a few packages to add.
- Run the mingw-get GUI from your desktop by double clicking the "MinGW Installer" shortcut.
- Right click the following list of packages (bin) within the right pane and select "Mark for Installation". Use the left navigation tree to filter categories.
- Basic Setup
mingw-developer-toolkitmingw32-basemingw32-gcc-g++
- All Packages
msys-wget- MinGW Libraries
- MinGW Standard Libraries
mingw32-libpthread-oldmingw32-libpthreadgc
- MinGW Standard Libraries
- Basic Setup
- From the GUI menu navigate to Installation > Apply Changes
- This will take some time to complete.
- Currently some packages should be downgraded (https://github.com/mozilla/rust/issues/5878)
Git Installation
If you already have Git installed and available on the path you may skip this section. You should be able to use the git command from your msys shell.
- Install git for windows from http://git-scm.com/download/win
- Uncheck Associate .sh files to be run with Bash from within the components screen.
- Select the option to Run Git from the Windows Command Prompt.
- It is recommended to choose the option to Checkout as-is, commit Unix-style line endings.
- Open a new msys console and type
git --versionto verify installation.
- Note: if your shell (explorer) does not return after installation, start the task manager and navigate to File > Run New Task... then enter
explorer.
Python27 Installation
If you already have python installed and on the path, you may skip this section.
- Get the Python27 installer from http://www.python.org/getit/
- I am using "Python 2.7.5 Windows X86-64 Installer"
- Accept the defaults, please.
- Add python to your system path: http://stackoverflow.com/a/6318188/458550
Clone Rust
- Navigate to a place on your file system where you feel comfortable downloading the Rust repository.
C:\projectsis a nice cozy spot!
- execute
git clone git://github.com/mozilla/rust.gitto clone the Rust repository into a newrustdirectory.
Configure & Build
-
Navigate to the directory where you cloned rust from within the msys shell. For me that is
cd /C/Projects/rust. -
Run the command
./configure- This will take a while!
-
When that completes run the command
make- This will take much longer!
-
Get your sad face ready because this build will fail. Eventually you should get an error such as this:
--------------------------- rustc.exe - Application Error --------------------------- The application was unable to start correctly (0xc0000142). Click OK to close the application. --------------------------- OK --------------------------- -
Download
libstdc++-4.6.2-1-mingw32-dll-6.tar.lzmafrom http://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version4/gcc-4.6.2-1/libstdc%2B%2B-4.6.2-1-mingw32-dll-6.tar.lzma/download and extract the contained libstdc++-6.dll into the\rust\i686-pc-mingw32\stage0\binfolder.- Try running
rustc.exeto confirm the fix.
- Try running
-
Run the
makecommand again.- This will take a really long time!
Rust is Ready
User@Machine /c/projects/rust/i686-pc-mingw32/stage2/bin
$ rustc.exe hello.rs
User@Machine /c/projects/rust/i686-pc-mingw32/stage2/bin
$ hello
Hello, world.
Moving Rust
If you want to move rust to a more permanent location on your system (for example C:\Program Files) you must preserve a little bit of structure. If you fail to do this correctly you may receive errors such as can't find crate for `std` . The contents of the stage2/bin folder must be contained within a folder named bin. The simplest way to do this is the following:
- Copy the contents of
stage2/bintoC:\Program Files\rust\bin- Be sure to include the
rustcfolder too
- Be sure to include the
- Add
;C:\Program Files\rust\binto your system path