# Windows build This guide details how to build CARLA from source on Windows. There are two parts. Part one details system requirements and installations of required software, and part two details how to actually build and run CARLA. The build process is long (4 hours or more) and involves several kinds of software. It is highly recommended to read through the guide fully before starting. If you come across errors or difficulties then have a look at the **[F.A.Q.](build_faq.md)** page which offers solutions for the most common complications. Alternatively, use the [CARLA forum](https://github.com/carla-simulator/carla/discussions) to post any queries you may have. - [__Part One: Prerequisites__](#part-one-prerequisites) - [System requirements](#system-requirements) - [Software requirements](#software-requirements) - [Minor installations](#minor-installations) - [Python dependencies](#python-dependencies) - [Major installations](#major-installations) - [Visual Studio 2019](#visual-studio-2019) - [Unreal Engine](#unreal-engine) - [__Part Two: Build CARLA__](#part-two-build-carla) - [Clone the CARLA repository](#clone-the-carla-repository) - [Get assets](#get-assets) - [Set Unreal Engine environment variable](#set-unreal-engine-environment-variable) - [Build CARLA](#build-carla) - [Other make commands](#other-make-commands) --- ## Part One: Prerequisites In this section you will find details of system requirements, minor and major software installations and Python dependencies that are required before you can begin to build CARLA. ### System requirements * __x64 system.__ The simulator should run in any 64 bits Windows system. * __165 GB disk space.__ CARLA itself will take around 32 GB and the related major software installations (including Unreal Engine) will take around 133 GB. * __An adequate GPU.__ CARLA aims for realistic simulations, so the server needs at least a 6 GB GPU although 8 GB is recommended. A dedicated GPU is highly recommended for machine learning. * __Two TCP ports and good internet connection.__ 2000 and 2001 by default. Make sure that these ports are not blocked by firewalls or any other applications. !!! Warning __If you are upgrading from CARLA 0.9.12 to 0.9.13__: you must first upgrade the CARLA fork of the UE4 engine to the latest version. See the [__Unreal Engine__](#unreal-engine) section for details on upgrading UE4 ### Software requirements #### Minor installations * [__CMake__](https://cmake.org/download/) generates standard build files from simple configuration files. __We recommend you use version 3.15+__. * [__Git__](https://git-scm.com/downloads) is a version control system to manage CARLA repositories. * [__Make__](http://gnuwin32.sourceforge.net/packages/make.htm) generates the executables. It is necessary to use __Make version 3.81__, otherwise the build may fail. If you have multiple versions of Make installed, check that you are using version 3.81 in your PATH when building CARLA. You can check your default version of Make by running `make --version`. * [__7Zip__](https://www.7-zip.org/) is a file compression software. This is required for automatic decompression of asset files and prevents errors during build time due to large files being extracted incorrectly or partially. * [__Python3 x64__](https://www.python.org/downloads/) is the main scripting language in CARLA. Having a x32 version installed may cause conflict, so it is highly advisable to have it uninstalled. !!! Important Be sure that the above programs are added to the [environment path](https://www.java.com/en/download/help/path.xml). Remember that the path added should correspond to the progam's `bin` directory. #### Python dependencies Starting with CARLA 0.9.12, users have the option to install the CARLA Python API using `pip3`. Version 20.3 or higher is required. To check if you have a suitable version, run the following command: ```sh pip3 -V ``` If you need to upgrade: ```sh pip3 install --upgrade pip ``` You must install the following Python dependencies: ```sh pip3 install --user setuptools pip3 install --user wheel ``` #### Major installations ##### Visual Studio 2019 Get the 2019 version of Visual Studio from [here](https://developerinsider.co/download-visual-studio-2019-web-installer-iso-community-professional-enterprise/). Choose __Community__ for the free version. Use the _Visual Studio Installer_ to install three additional elements: * __Windows 8.1 SDK.__ Select it in the _Installation details_ section on the right or go to the _Indivdual Components_ tab and look under the _SDKs, libraries, and frameworks_ heading. * __x64 Visual C++ Toolset.__ In the _Workloads_ section, choose __Desktop development with C++__. This will enable a x64 command prompt that will be used for the build. Check that it has been installed correctly by pressing the `Windows` button and searching for `x64`. Be careful __not to open a `x86_x64` prompt__. * __.NET framework 4.6.2__. In the _Workloads_ section, choose __.NET desktop development__ and then in the _Installation details_ panel on the right, select `.NET Framework 4.6.2 development tools`. This is required to build Unreal Engine. !!! Important Other Visual Studio versions may cause conflict. Even if these have been uninstalled, some registers may persist. To completely clean Visual Studio from the computer, go to `Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\layout` and run `.\InstallCleanup.exe -full` !!! Note It is also possible to use Visual Studio 2022 using the above steps and substituting the Windows 8.1 SDK for the Windows 11/10 SDK. To override the default Visual Studio 2019 Generator in CMake, specify GENERATOR="Visual Studio 17 2022" when using the makefile commands (see [table](build_windows.md#other-make-commands)). You may specify any generator that works with the build commands as specific in the build scripts, for a full list run `cmake -G` (Ninja has been tested to work for building LibCarla so far). ##### Unreal Engine Starting with version 0.9.12, CARLA uses a modified fork of Unreal Engine 4.26. This fork contains patches specific to CARLA. Be aware that to download this fork of Unreal Engine, __you need to have a GitHub account linked to Unreal Engine's account__. If you don't have this set up, please follow [this guide](https://www.unrealengine.com/en-US/ue4-on-github) before going any further. To build the modified version of Unreal Engine: __1.__ In a terminal, navigate to the location you want to save Unreal Engine and clone the _carla_ branch: ```sh git clone --depth 1 -b carla https://github.com/CarlaUnreal/UnrealEngine.git . ``` !!! Note Keep the Unreal Engine folder as close as `C:\\` as you can because if the path exceeds a certain length then `Setup.bat` will return errors in step 3. __2.__ Run the configuration scripts: ```sh Setup.bat GenerateProjectFiles.bat ``` __3.__ Compile the modified engine: >1. Open the `UE4.sln` file inside the source folder with Visual Studio 2019. >2. In the build bar ensure that you have selected 'Development Editor', 'Win64' and 'UnrealBuildTool' options. Check [this guide](https://docs.unrealengine.com/en-US/ProductionPipelines/DevelopmentSetup/BuildingUnrealEngine/index.html) if you need any help. >3. In the solution explorer, right-click `UE4` and select `Build`. __4.__ Once the solution is compiled you can open the engine to check that everything was installed correctly by launching the executable `Engine\Binaries\Win64\UE4Editor.exe`. !!! Note If the installation was successful, this should be recognised by Unreal Engine's version selector. You can check this by right-clicking on any `.uproject` file and selecting `Switch Unreal Engine version`. You should see a pop-up showing `Source Build at PATH` where PATH is the installation path that you have chosen. If you can not see this selector or the `Generate Visual Studio project files` when you right-click on `.uproject` files, something went wrong with the Unreal Engine installation and you will likely need to reinstall it correctly. !!! Important A lot has happened so far. It is highly advisable to restart the computer before continuing. --- ## Part Two: Build CARLA ### Clone the CARLA repository
The button above will take you to the official repository of the project. Either download from there and extract it locally or clone it using the following command: ```sh git clone https://github.com/carla-simulator/carla ``` !!! Note The `master` branch contains the current release of CARLA with the latest fixes and features. Previous CARLA versions are tagged with the version name. Always remember to check the current branch in git with the command `git branch`. ### Get assets Download the __latest__ assets to work with the current version of CARLA by running the following command in the CARLA root folder: ```sh Update.bat ``` The assets will be downloaded and extracted to the appropriate location if have 7zip installed. If you do not have this software installed, you will need to manually extract the file contents to `Unreal\CarlaUE4\Content\Carla`. To download the assets for a __specific version__ of CARLA: 1. From the root CARLA directory, navigate to `\Util\ContentVersions.txt`. This document contains the links to the assets for all CARLA releases. 2. Extract the assets in `Unreal\CarlaUE4\Content\Carla`. If the path doesn't exist, create it. 3. Extract the file with a command similar to the following: ```sh tar -xvzf