634e418777
Ensure that actually only the unreal sysroot is deployed for all C as well C++ compilations including dependencies. That ensures the server is NOT anymore linked against the system glibc (which is in Ubuntu22.04 incompatible with the Unreal one). As a consequence no local clang installation required anymore to build under Linux. Harmonized naming split into client/server (instead of libcpp and libstdcpp) to ensure nothing mixed up (and there were things mixed up before!) Refactor C# Unreal build using CarlaRules base class to provide common functionality. Fixing windows build without ROS2 and added intitial windows build with ROS2 Restrict to one DDS-Domain-Participant for carla-server (Fixes bind address already in use exception on with ROS2). Due to continued segfaults in reallocations of MallocBinned2 in conjunction with ROS2 enforce using AnsiMalloc calls under Linux (see https://forums.unrealengine.com/t/dealing-with-allocator-mismatches-with-external-libraries/1416830) Use C++20 to allow for more robust struct initialization (see https://en.cppreference.com/w/cpp/language/aggregate_initialization), added Eigen C++20 patches and required CARLA changes to cope with C++20 compilation errors Be aware: This change requires the Unreal PR (https://github.com/CarlaUnreal/UnrealEngine/pull/23) Move forward to g++-13 Minors: - Fix make clean call - Update osm2odr commit with build fix (https://github.com/carla-simulator/sumo/pull/6) - Update ad-rss to 4.4.5 (supports boost 1.80) - Fix windows install scripts and forward arguments for building libcarla - Adapt codeformat.py to python3 using clang-format-14 |
||
---|---|---|
.. | ||
.gitignore | ||
Makefile | ||
README.md | ||
ToolChain.cmake | ||
main.cpp |
README.md
C++ Client Example
This example creates an application using CARLA's C++ API to connect and control the simulator from C++.
Compile and run
Use the Makefile provided (Linux only), to compile and run the example. Note that it expects to have a simulator running at port 2000.
make run
How it works
In order to link our application against LibCarla, we need to compile LibCarla with the same compiler and configuration we are using with our application. To do so, we generate a CMake tool-chain file specifying the compiler and flags we want
# Example ToolChain.cmake
set(CMAKE_C_COMPILER /usr/bin/clang-8)
set(CMAKE_CXX_COMPILER /usr/bin/clang++-8)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -O3 -DNDEBUG" CACHE STRING "" FORCE)
We pass this file to CMake when compiling LibCarla.client
cd /path/to/carla-root-folder
make setup
cd /path/to/build-folder
cmake \
-G "Ninja" \
-DCMAKE_BUILD_TYPE=Client \
-DLIBCARLA_BUILD_RELEASE=ON \
-DLIBCARLA_BUILD_DEBUG=OFF \
-DLIBCARLA_BUILD_TEST=OFF \
-DCMAKE_TOOLCHAIN_FILE=/path/to/ToolChain.cmake \
-DCMAKE_INSTALL_PREFIX=/path/to/install-folder \
/path/to/carla-root-folder
ninja
ninja install
This will generate the following structure at the provided install path
libcarla-install
├── include
│ ├── carla
│ ├── cephes
│ ├── pugixml
| ├── ...
│ └── system
│ ├── boost
│ ├── recast
│ └── rpc
└── lib
├── libcarla_client.a
├── librpc.a
├── libboost_filesystem.a
└── ...
Our application needs to be linked at minimum against libcarla_client.a
,
librpc.a
, libRecast.a
, and libDetour*.a
. If we make use of IO
functionality and/or image processing we would need to link against
boost_filesystem
, png
, tiff
, and/or jpeg
.
For more details take a look at the Makefile provided.