diff --git a/README.md b/README.md index 02648f94c..a299fe652 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,41 @@ CARLA UE4 Plugin ================ -To build within a project [CarlaServer](Source/CarlaServer/README.md) needs to -be built first. +Plugin for Unreal Engine 4. -See [carla-ue4](https://bitbucket.org/carla-cvc/carla-ue4). +Compiling a UE4 project with CARLA plugin +----------------------------------------- +Clone or copy the files of this repository under the folder +`/Plugins/Carla`. +Build CarlaServer located at `/Plugins/Carla/Source/CarlaServer`, +follow the instructions [here](Source/CarlaServer/README.md) to build all the +necessary dependencies too. + +Now compile the Unreal project. + +#### Linux + +Opening the .uproject file with UE4Editor usually triggers a recompile. If not +you can follow the next steps to do it manually. + +Generate project files + + $ /GenerateProjectFiles.sh -project="/.uproject" -game -engine + +Build project in the in-editor configuration + + $ cd + $ make Editor + +Now you can launch the editor. + +#### Windows + +Usually double-clicking the .uproject file triggers a recompile. + +To build from Visual Studio, right-click the project file and select "Generate +Visual Studio Files". Open the generated solution (.sln) and compile. You can +change the build configuration to development/debug both in-editor and +standalone game. diff --git a/Source/Carla/Carla.Build.cs b/Source/Carla/Carla.Build.cs index 35c81bc56..852df1f1a 100644 --- a/Source/Carla/Carla.Build.cs +++ b/Source/Carla/Carla.Build.cs @@ -127,7 +127,12 @@ public class Carla : ModuleRules { if (Target.Platform == UnrealTargetPlatform.Linux) { - PublicAdditionalLibraries.Add("turbojpeg"); + string TurboJPEGLibPath = System.Environment.GetEnvironmentVariable("TURBOJPEG_LIB_PATH"); + if (string.IsNullOrEmpty(TurboJPEGLibPath) || !System.IO.Directory.Exists(TurboJPEGLibPath)) + { + throw new System.Exception("TURBOJPEG_LIB_PATH is not defined, or points to a non-existant directory, please set this environment variable."); + } + PublicAdditionalLibraries.Add(Path.Combine(TurboJPEGLibPath, "libturbojpeg.a")); } } diff --git a/Source/CarlaServer/CMakeLists.txt b/Source/CarlaServer/CMakeLists.txt index 7be6ae133..83c5731e0 100644 --- a/Source/CarlaServer/CMakeLists.txt +++ b/Source/CarlaServer/CMakeLists.txt @@ -90,8 +90,12 @@ endif (UNIX) if (UNIX) - set(TurboJPEG_LIBRARIES ${TurboJPEG_LIBRARIES} turbojpeg) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWITH_TURBOJPEG") + if (EXISTS $ENV{TURBOJPEG_LIB_PATH}) + set(TurboJPEG_LIBRARIES ${TurboJPEG_LIBRARIES} $ENV{TURBOJPEG_LIB_PATH}/libturbojpeg.a) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWITH_TURBOJPEG") + else (EXISTS $ENV{TURBOJPEG_LIB_PATH}) + message(FATAL_ERROR "TURBOJPEG_LIB_PATH is not defined, or points to a non-existant directory, please set this environment variable.") + endif (EXISTS $ENV{TURBOJPEG_LIB_PATH}) elseif (WIN32) diff --git a/Source/CarlaServer/README.md b/Source/CarlaServer/README.md index 87cbdf38b..86bc62781 100644 --- a/Source/CarlaServer/README.md +++ b/Source/CarlaServer/README.md @@ -12,19 +12,27 @@ Install boost, protobuf, cmake and ninja. $ sudo apt-get install libprotobuf-dev protobuf-compiler libboost-all-dev cmake ninja-build -Run make - - $ make - Requires to manually compile [TurboJPEG](https://github.com/libjpeg-turbo/libjpeg-turbo). Follow the instructions -[here](https://github.com/libjpeg-turbo/libjpeg-turbo/blob/master/BUILDING.md). -At the configure step add PIC compile option +[here](https://github.com/libjpeg-turbo/libjpeg-turbo/blob/master/BUILDING.md), +but at the configure step make sure to use the compile option -fPIC otherwise +Unreal is not able to link $ {source_directory}/configure CFLAGS='-fPIC' $ make +Most probably libraries are generated under `.lib` folder. + +Set the environment variable `TURBOJPEG_LIB_PATH` to a folder containing the +generated `libturbojpeg.a` (e.g., add +`export TURBOJPEG_LIB_PATH=` to your `~/.bashrc`). This way +we can find the right version of the library from Unreal Build Tool. + +Back to CarlaServer folder, run make + + $ make + #### Windows Note: JPEG compression is not implemented on Windows, the server won't send any