carla/Docs/how_to_build_on_windows.md

184 lines
6.5 KiB
Markdown
Raw Normal View History

2018-03-22 01:16:56 +08:00
<h1>How to build CARLA on Windows</h1>
2017-09-07 21:55:41 +08:00
2018-06-12 21:31:11 +08:00
<h3>Necessary software</h3>
2018-04-19 00:34:09 +08:00
- [Git](https://git-scm.com/downloads)
- [Make](http://gnuwin32.sourceforge.net/downlinks/make-bin-zip.php)
- [Cmake](https://cmake.org/download/)
!!! important
Be sure that these programs are added to your path, so you can use them from your command prompt.
Also:
- [Unreal Engine](https://www.unrealengine.com/download) (v4.18.x)
- [Visual Studio](https://www.visualstudio.com/downloads/) (2017 preferably)
2018-06-12 21:31:11 +08:00
<h3>Environment Setup</h3>
2018-04-19 00:34:09 +08:00
In order to build CARLA you must **enable the x64 Visual C++ Toolset**.
I recommend to use this environment for everything you do in this tutorial.
2018-04-19 00:34:09 +08:00
You have different options:
2018-06-14 22:08:13 +08:00
- **Recomended:** Use [`Visual Studio x64 Native Tools Command Prompt`](https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs). Just press the `Win` button and search for `x64` (be careful to not **unintentionally open a `x86_x64` prompt**), because the name of this Command Prompt can change depending on the lenguage you have Visual Studio installed.
2018-04-19 00:34:09 +08:00
- [Enable a 64-Bit Visual C++ Toolset on the Command Line](https://msdn.microsoft.com/en-us/library/x4d2c09s.aspx) (the instructions will depend on the version of VS that you have).
2018-06-14 22:08:13 +08:00
!!! note
Take care if you have **Cygwin** installed. This could cause the errors like
`/usr/bin/sh: rd: command not found` While executing `Reuild.bat`.
2018-06-12 21:31:11 +08:00
<h3>Clone the repository</h3>
2018-06-11 23:47:45 +08:00
Go to the path you want to install CARLA and use git to download the project using the following command:
2018-04-19 00:34:09 +08:00
```cmd
git clone https://github.com/carla-simulator/carla.git
```
2018-06-11 23:47:45 +08:00
and get in the created folder:
```cmd
cd carla
```
# Automatic installation
Once you have downloaded the repo you can start with the automatic installation.
2018-06-11 23:47:45 +08:00
This process may take a while, it will download and install the necessary Boost and Protobuf libraries. Expect 20-40 minutes, depending on your hardware and internet connection.
Script | Use
------------- | ----
`Setup.bat` | Downloads and installs all the external dependencies, automatically calling the scripts in `Util/InstallersWin/`.
`Rebuild.bat` | Builds carlaserver and launch the Unreal project.
2018-06-12 21:31:11 +08:00
<h3>Installation</h3>
1. After navigate to your carla folder, run:
2018-06-11 23:47:45 +08:00
Setup.bat -j 8 --boost-toolset msvc-14.1
`-j n` will try to parallelize the git download and NMake compilation. If not specified, no optimization will be made.
2018-06-11 23:47:45 +08:00
2018-06-12 21:31:11 +08:00
To see available commands, like which `--boost-toolset` you have to use depending on your Visual Studio version, use:
2018-06-11 23:47:45 +08:00
Setup.bat --help
1. When it's done, and if everything went well, `Setup.bat` will provide a link where you can download the assets manually. If you get some errors you can try the **Manual Installation**, open a new issue on [GitHub](https://github.com/carla-simulator/carla/issues/) or just ask on the [Windows Discord channel](https://discord.gg/42KJdRj).
2018-06-11 23:47:45 +08:00
1. Unzip these assets into `Unreal/CarlaUE4/Content`. Create it if the folder is not there.
1. Now let's compile carlaserver and start the Unreal project. Run:
Rebuild.bat
1. Later on it will ask you to rebuild:
UE4Editor-CarlaUE4.dll
UE4Editor-Carla.dll
Agree and the project will be opened in the Unreal Engine in a few minutes.
# Manual Installation
2018-06-12 21:31:11 +08:00
!!! note
Since version **0.8.3**, it is recomended to follow the automatic installation.
2018-06-11 23:47:45 +08:00
2018-06-12 21:31:11 +08:00
<h3>Download the assets</h3>
2018-04-23 20:58:28 +08:00
Download the assets from the version you need. Take a look at [`Util/ContentVersions.txt`](https://github.com/carla-simulator/carla/blob/master/Util/ContentVersions.txt) and follow the provided instructions to build the download link from the version's hash.
2018-04-19 00:34:09 +08:00
Create the folder `Content` in `Unreal/CarlaUE4/` and unzip the content you just downloaded here.
2018-06-12 21:31:11 +08:00
<h3>Dependencies</h3>
2018-04-19 00:34:09 +08:00
Download and build **for win64**:
- Boost 1.64
- Protobuf 3.3.2
2018-06-12 21:31:11 +08:00
<h3>Building Boost for CARLA</h3>
Follow the official documentation to compile boost.
2018-06-12 21:31:11 +08:00
Put the generated binaries in `Util/Build/boost-install`:
```c
Util
└── Build
└── boost-install
├── boost-1_64
| └── boost
| ├── accumulators
| ├── algorithm
| ├── align
| └── [...] // and all the other libraries
└── lib
├── libboost_date_time-vc141-mt-1_64.lib
└── libboost_system-vc141-mt-1_64.lib
```
2018-04-19 00:34:09 +08:00
2018-06-12 21:31:11 +08:00
<h3>Building Protobuf for CARLA</h3>
<h4>From our batch file</h4>
2018-04-19 00:34:09 +08:00
Just use [this batch](https://gist.github.com/marcgpuig/57946f9b684f64e5f08487089c437ea3) script, it will download and compile a ready-to-use version. Put it in`Util/Build` and just run it.
2018-06-12 21:31:11 +08:00
<h4>Manually</h4>
2018-04-19 00:34:09 +08:00
If something goes wrong, just follow the protobuf [cmake tutorials](https://github.com/google/protobuf/blob/master/cmake/README.md), but add these cmake arguments:
```
-DCMAKE_BUILD_TYPE=Release
-Dprotobuf_BUILD_TESTS=OFF
-DCMAKE_CXX_FLAGS_RELEASE=/MD
-Dprotobuf_MSVC_STATIC_RUNTIME=OFF
```
Put the generated binaries in `Util/Build/protobuf-install`.
2018-06-12 21:31:11 +08:00
<h3>Compiling CARLA server</h3>
2018-04-19 00:34:09 +08:00
With your Visual Studio propmt, navigate into the `carla` folder where you cloned the repo with
```cmd
cd carla
```
and use:
```cmd
path\to\carla> make
```
2018-06-12 21:31:11 +08:00
If you have done everything alright, **carla server** must be installed successfully in `Unreal/CarlaUE4/Plugins/Carla/CarlaServer`.
2018-04-19 00:34:09 +08:00
2018-06-12 21:31:11 +08:00
<h3>Launch Unreal Engine</h3>
2018-04-19 00:34:09 +08:00
Double click `Unreal/CarlaUE4/CarlaUE4.uproject` and it will ask you to rebuild:
2018-04-19 00:34:09 +08:00
UE4Editor-CarlaUE4.dll
UE4Editor-Carla.dll
2018-04-19 00:34:09 +08:00
Agree.
2018-06-12 21:31:11 +08:00
<h3>Compilation failures</h3>
2018-04-19 00:34:09 +08:00
If there are problems generating the dlls, right click on `CarlaUE4.uproject` and select `Generate Visual Studio project files`, so you can try compiling from the Visual Studio Editor and check the errors.
2018-06-12 21:31:11 +08:00
# Recompiling
<h4>Automatic</h4>
Just run `Rebuild.bat`:
2018-04-19 00:34:09 +08:00
```
2018-06-12 21:31:11 +08:00
path\to\carla> Rebuild
```
<h4>Manual</h4>
You must delete the following folders to **completely rebuild** your project:
```cmd
2018-04-19 00:34:09 +08:00
Unreal/CarlaUE4/Binaries
Unreal/CarlaUE4/Intermediate
Unreal/CarlaUE4/Plugins/Carla/Binaries
Unreal/CarlaUE4/Plugins/Carla/Intermediate
```
2018-06-12 21:31:11 +08:00
Then you can clean the project and compile it again:
2018-04-19 00:34:09 +08:00
2018-06-12 21:31:11 +08:00
```
2018-04-19 00:34:09 +08:00
path\to\carla> make clean & make
```
You can do it more automatically with your prompt in `carla` folder:
2018-06-12 21:31:11 +08:00
```
2018-04-19 00:34:09 +08:00
path\to\carla> rmdir /q /s Unreal/CarlaUE4/Binaries Unreal/CarlaUE4/Intermediate Unreal/CarlaUE4/Saved Unreal/CarlaUE4/Plugins/Carla/Binaries Unreal/CarlaUE4/Plugins/Carla/Intermediate
path\to\carla> make clean
path\to\carla> make
path\to\carla> Unreal/CarlaUE4/CarlaUE4.uproject
```