User:Oldman/A layman's guide/How to compile ReactOS
This guide shows you how to make your own working environment, down load the ReactOS source code and then compile it using the Reactos Build Evironment. Section one covers Windows and section two covers Unix and section three applies to either.
- 1 Section one - Windows
- 1.1 Setting up a local working environment
- 1.2 Compiling the source (32 bit)
- 1.3 Compiling the source (64 bit)
- 1.4 Screenshots
- 2 Section two - Unix
- 3 Section three - General
Section one - Windows
Setting up a local working environment
Next you will need to create a master folder to keep all the next folders in one place. This folder can be created in C: or D: (or any other drive partition and name it whatever you want), example D:\ReactOS_Development or C:\ROS.
Create the following folders in your master folder:
1. \source (the name does not matter - you will download the source tree into this folder).
2. \compiled (the name does not matter - this is the output folder where the binaries are complied to and the ISO is created).
3. \RosBE (this is where you will install RosBE).
You should now have something like the following examples.
Using example No2, within D:\ReactOS_Development\ you will have created a Compiled folder, a RosBE folder and a Source folder. Next, navigate into D:\ReactOS_Development\Source and right click within the folder, then select Git Clone, then in the next window, enter this url https://github.com/reactos/reactos.git; this will create a reactos folder and download the current source tree into it.
I have noticed this behaviour with Git; if you first copy the url, then click in the source folder, you will find that Git has put the copied url in the Url input and put the path to your source folder with the addition of reactos, in the Directory input. See   [3a] [3b]  in the Getting the source with Git section below.
For how to update your local source, see the subsection Updating a local source tree with Git.
Having downloaded the source you will now need to download and install the ReactOS Build Environment    (a link to the latest version (Windows and Unix) can be found here: https://www.reactos.org/wiki/ReactOS_Build_Environment) into D:\ReactOS_Development\RosBE.
If you have git, TortoiseGit, RosBE installed, and ReactOS master cloned into your source directory, you are ready to start the compilation process.
Note: if want to have a script to automate most of the above work for you, then there is a script here to do just that.
Compiling the source (32 bit)
To continue with my example; start RosBE, and from it's command prompt:  (Note: If you did not install RosBE with the desktop shortcut option selected, then open a command prompt window and navigate to D:\ReactOS_Development\RosBE and type RosBE to start it.) and within RosBE,
1. Navigate to D:\ReactOS_Development\Compiled and type D:\ReactOS_Development\Source\reactos\configure ninja
2. Still within D:\ReactOS_Development\Compiled type ninja bootcd
3. Still within D:\ReactOS_Development\Compiled type ninja livecd
4. Still within D:\ReactOS_Development\Compiled type ninja hybridcd
or if want all three ISO images
5. Still within D:\ReactOS_Development\Compiled type ninja bootcd livecd hybridcd
Now you should find the bootcd and/or the livecd and/or hybridcd in D:\ReactOS_Development\Compiled\reactos.
If you have problems compiling after you have updated your local source tree, try typing ninja clean and then start again at step 1 above.
If you are doing something different to the suggested example above and have not created a separate directory for the compiled source, then when using RosBE, you are in the reactos directory and type configure ninja or configure make, you will find that RosBE has created a new directory in the reactos directory, called output-MinGW-i386. You must change directories into this output-MinGW-i386 directory to issue the commands ninja livecd or ninja bootcd (make bootcd or make livecd). The created ISO will then be in the output-MinGW-i386 directory.
Compiling the source (64 bit)
- These instructions are only applicable to RosBE 2.2.0 (which has not yet been released to date:2020-02-20) and above.
- They do not work with the earlier RosBE 2.1.6.
- 64 bit gcc is not currently supported.
- RosBE needs to be configured to use msvc to compile a 64 bit version of ReactOS.
You are advised to have a different compiled directory folder from the 32 bit, to separate the different codes.
The compile instructions are the same as for the 32 bit above. All that you have to do, is to change to 64 bit mode with the command charch amd64 like so:
To change back to the 32 bit mode, use the same command charch, with i386 in place of amd64 and do not forget to change to your 32 bit directory folder.
Getting the source with Git
The following window will then open.
 If the URL is correct (https://github.com/reactos/reactos.git) and the Directory (for the source) is correct, then the rest can be left as they are. Click on the OK button to start the download process.
Updating a local source tree with Git
Configuring and installing RosBE
Note: If you select AMD64 compiler and Desktop shortcuts, you will have two RosBE shortcuts on the desktop, one for the 32 bit compiler and one for the AMD64 compiler.
Compiling with RosBE
In the screenshot of RosBE, you can see that the working directory has been changed from source to compiled, then configure ninja has been executed and completed. The command line now shows ninja bootcd waiting to be executed.
Note: RosBE 2.2.0 amd64 displays with blue text and the for 32 bit compile mode, with green text, as above.
Changing modes in RosBE
Note: If you change from 32 bit compile mode to amd64, it will still have green text.
Section two - Unix
The ReactOS Build Environment requires the following software to be installed on Unix systems:
There is a script in the unix section of Miscellaneous, which can automate the checking for and the installation of the above software.
Setting up a local working environment
You will now need to download the current ReactOS Build Environment (RosBE), from https://www.reactos.org/wiki/ReactOS_Build_Environment
Unpack the RosBE installation files to /home/RosBE-Unix-*.*.* directory.
(*.*.* = version number, currently 2.2.1)
Create the following folders /home/RosBuild then /home/RosBuild/RosBE (install RosBE in this folder).
Note: The default directory for RosBE, is /usr/local/RosBE, if you prefer, you can use that.
To continue with my example; Open the folder /home/RosBE-Unix-*.*.* and right click within , for the menu, Window - Terminal Here .
In the terminal window, run the builder script by typing ./RosBE-Builder.sh. If it reports any missing tools , you will need to install them (see list above).
Then run the script as before, and if it reports all tools OK , then you can continue.
To follow my example, type /home/RosBuild/RosBE for the install directory and then follow the instructions from the running script.
If all went well, then it will ask you about creating a shortcut, just follow the instructions.
I created the shortcut in /home then copied it onto the desktop and checked to see if it ran RosBE.
To populate your source folder, you will need to open a terminal window within the empty source folder; right click - Window - Terminal Here, then at the command prompt, type:
git clone https://github.com/reactos/reactos.git.
This will create a folder called reactos and download the main source code.
To get the revision number, right click on the reactos folder and select Window - Terminal Here, then at the command prompt, type: git describe, which will display something like this 0.4.7-dev-532-g3cd76b91b5.
The alternative to the 'Right click-Window-Terminal Here' method, is to type the full address, eg. /home/RosBuild/source.
To update the source code, right click within the reactos folder and select Window - Terminal Here, then at the command prompt type:
git pull https://github.com/reactos/reactos.git
NOTE: You must be actually in the source folder to clone and actually in the reactos folder to update the source or get the revision number.
There is also a script in the Miscellaneous unix section, that can automate the setting up of a working environment.
Compiling the source
Start RosBE and at the terminal command prompt type cd /home/RosBuild/compiled (or the directory that you want ReactOS to be built into).
Then type /home/RosBuild/source/reactos/configure.sh.
When the script finishes, type cd /home/RosBuild/compiled/reactos/
and then ninja livecd or ninja bootcd
If you are doing something different to the suggested example above and have not created a separate directory for the compiled source, then when using RosBE, you are in the reactos directory and type configure.sh, you will find that RosBE has created a new directory in the reactos directory, called output-MinGW-i386. You must change directories into this output-MinGW-i386 directory to issue the commands ninja livecd or ninja bootcd (make does not work in Unix RosBE). The created ISO will then be in the output-MinGW-i386 directory.
Section three - General
Getting the source of a single branch
You may decide you want to download the source of one of the branches, so this is how to do it from the command prompt using the directory structure from the previous examples.
In a terminal widow, navigate to your local source directory and type the following:
git clone --single-branch --branch releases/0.4.13 https://github.com/reactos/reactos.git 0.4.13
Replace releases/0.4.13 with the branch of your choice.
git ..................................................................... Starts git.
clone ............................................................... The command that tells git to clone the Repository.
--single-branch .............................................. This tells git to only clone a single branch.
--branch .......................................................... The switch for a branch.
releases/0.4.13 .............................................. The branch path and name.
https://github.com/reactos/reactos.git ....... The URL of the Reactos git repository.
0.4.13 ............................................................... The folder to clone into.
If you omit to put a folder name after the URL, it will use the default from github, which will be reactos. You could use any name you choose, as in the following example, where mybranch is used; if the folder does not exist, then it will be created.
git clone --single-branch --branch releases/0.4.13 https://github.com/reactos/reactos.git mybranch
Selecting a branch
In your browser, go to https://github.com/reactos/reactos, which will display the page shown in the image above.
To select a branch, click on the down arrow (as shown in the above image), then choose a branch from the drop-down list; you may need to scroll down the list.
Getting the source of a repository
If you want to clone a repository from https://github.com/reactos such as rapps-db for example, then add the repository name to the end of the url, like so:
git clone https://github.com/reactos/rapps-db
or developer-web-interface, then it would look like this:
git clone https://github.com/reactos/developer-web-interface
Using the example of rapps-db, if you wanted to clone it into another directory other than rapps-db, then you would leave a space at the end of the url and then type the chosen name for the directory, like so:
git clone https://github.com/reactos/rapps-db software_database (software_database is only a suggestion, use your own name).