Skip to content
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 6 additions & 30 deletions Docs/build_linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,65 +38,41 @@ CARLA requires many different kinds of software to run. Some are built during th

```sh
sudo apt-get update &&
sudo apt-get install wget software-properties-common &&
sudo add-apt-repository ppa:ubuntu-toolchain-r/test &&
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add
sudo apt-get install wget software-properties-common
```

!!! Warning
The following commands depend on your Ubuntu version. Make sure to choose accordingly.

To avoid compatibility issues between Unreal Engine and the CARLA dependencies, use the same compiler version and C++ runtime library to compile everything. The CARLA team uses clang-8 (or clang-10 in Ubuntu 20.04) and LLVM's libc++. Change the default clang version to compile Unreal Engine and the CARLA dependencies.

__Ubuntu 22.04__.
```sh
sudo apt-add-repository "deb http://archive.ubuntu.com/ubuntu focal main universe"
sudo apt-get update
sudo apt-get install build-essential clang-10 lld-10 g++-7 cmake ninja-build libvulkan1 python python3 python3-dev python3-pip libpng-dev libtiff5-dev libjpeg-dev tzdata sed curl unzip autoconf libtool rsync libxml2-dev git git-lfs
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-10/bin/clang++ 180 &&
sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-10/bin/clang 180 &&
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 180
sudo apt-get install build-essential cmake ninja-build libvulkan1 python-is-python3 python3 python3-dev python3-pip libpng-dev libtiff5-dev libjpeg-dev tzdata sed curl unzip autoconf libtool rsync libxml2-dev git git-lfs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

g++ is required to build modules like ROS2 and pytorch.
Why do you think we should remove it from package installation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only the additional g++-7 is removed (as not required) and the corresponding update alternatives call
build-essentials should bring already the default system g++ with it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch about the build-essential package!

I have addicional worries about this change:
If we define the g++ version as system default one, this implies CARLA could be possibly build with huge number of g++ versions, as many users are building CARLA and we don't have any info about what distro are the using. On my understanding, define g++ version as system default adds the next risks:

  • Sometimes code built with different g++ versions my conclude on build errors or new defects.
  • Is not clear for CARLA contributors what is the minimum requiered version of g++ to mantain build backward compatibility when creating PRs.
  • I'm not sure if ROS2 and pytorch libraries have some restriction about what versions of the comipler to use.
  • It's pracmatic (usable) for the contributors to have a default version of g++ that is tested by us and we ensure is working. Otherwise, they could potentially have to deal with non desired build errors and this will take extra time for them. Anyway, I think we should provide a mechanism to the contributors to build with different versions of g++, but we also should provide a default stable g++ version for the contributors who don't expect to lose time dealing by unestable CARLA build sysmtem.

What are your thoughts about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, yes your fears make sense.
I would then approach from that side. Standard supported linux system is Ubuntu. Then I would go with the active LTS versions and support their standard g++ versions. Taking their EOL dates as supporting dates might be a bit too much as Ubuntu 14.04 goes EOL right now. So taking their "End of Standard Support" as basis might be more meaningful:
Ubuntu 22.04 LTS: June 2027, gcc-11
Ubuntu 20.04 LTS: April 2025, gcc-9
Therefore, I'd either define gcc-9 or gcc-11 as gold standard for now.

On pytorch, I don't know since I have to admit that I never worked so far with it on my own. On ROS2 the respective Ubuntu default compiler for sure works.

But if CARLA supports both active Ubuntu systems (and maybe have a build job for both of them in the background to ensure), then you don't need to install a specific version here. One should then rewrite the docu in the sense that the two active Ubuntu systems are supported. And if someone else with nother Linux-Distro wants to compile CALRA he/she should install either gcc-9 or gcc-11 (at the current point in time for sure ;-)
Still, then you don't need to change the build instructions for 22.04 and 20.04, and why not making the live harder for the restistent guys who are still using 18.04 or older; If they do use such old systems they should be aware of that and be able to handle to install other gcc versions on their own if they run into problems. Or they should just upgrade their system -- which is from system security perspective in each case adviceable.
The supported clang version is in each case clear, since it's the Unreal one... which will also change soon when swithing to Unreal 5.xx engine.
So you see: you might want to extend the notes in the docu around that topic a bit and "degrade" also 18.04 to a not adviced Linux -Distro, since it has some years "on the back" (don't know if one says that also in UK like that ... it's some German slang ;-)

Please discuss with the team and adapt the commit as you decide on your own. You should have the rights to do so, I believe.

Ah, so now it's Easter in Germany: Happy searching of Easter Eggs.

Copy link
Contributor

@xavisolesoft xavisolesoft Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy Easter!
We also celebrate Easter here at Barcelona :)

```

__Ubuntu 20.04__.
```sh
sudo apt-add-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal main"
sudo apt-get update
sudo apt-get install build-essential clang-10 lld-10 g++-7 cmake ninja-build libvulkan1 python python-dev python3-dev python3-pip libpng-dev libtiff5-dev libjpeg-dev tzdata sed curl unzip autoconf libtool rsync libxml2-dev git
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-10/bin/clang++ 180 &&
sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-10/bin/clang 180
sudo apt-get install build-essential cmake ninja-build libvulkan1 python python-dev python3-dev python3-pip libpng-dev libtiff5-dev libjpeg-dev tzdata sed curl unzip autoconf libtool rsync libxml2-dev git
```

__Ubuntu 18.04__.

```sh
sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic main"
sudo apt-get update
sudo apt-get install build-essential clang-8 lld-8 g++-7 cmake ninja-build libvulkan1 python python-pip python-dev python3-dev python3-pip libpng-dev libtiff5-dev libjpeg-dev tzdata sed curl unzip autoconf libtool rsync libxml2-dev git
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-8/bin/clang++ 180 &&
sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-8/bin/clang 180
sudo apt-get install build-essential cmake ninja-build libvulkan1 python python-pip python-dev python3-dev python3-pip libpng-dev libtiff5-dev libjpeg-dev tzdata sed curl unzip autoconf libtool rsync libxml2-dev git
```

__Ubuntu 16.04__.

```sh
sudo apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main" &&
sudo apt-get update
sudo apt-get install build-essential clang-8 lld-8 g++-7 cmake ninja-build libvulkan1 python python-pip python-dev python3-dev python3-pip libpng16-dev libtiff5-dev libjpeg-dev tzdata sed curl unzip autoconf libtool rsync libxml2-dev git
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-8/bin/clang++ 180 &&
sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-8/bin/clang 180
sudo apt-get install build-essential cmake ninja-build libvulkan1 python python-pip python-dev python3-dev python3-pip libpng16-dev libtiff5-dev libjpeg-dev tzdata sed curl unzip autoconf libtool rsync libxml2-dev git
```

__Previous Ubuntu versions__.

We strongly advise using Ubuntu 18.04 or later to build CARLA. However, you may attempt to build CARLA on older versions of Ubuntu with the following commands:

```sh
sudo apt-add-repository "deb http://apt.llvm.org/<code_name>/ llvm-toolchain-<code_name>-8 main" &&
sudo apt-get update
sudo apt-get install build-essential clang-8 lld-8 g++-7 cmake ninja-build libvulkan1 python python-pip python-dev python3-dev python3-pip libpng16-dev libtiff5-dev libjpeg-dev tzdata sed curl unzip autoconf libtool rsync libxml2-dev git
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-8/bin/clang++ 180 &&
sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-8/bin/clang 180
sudo apt-get install build-essential cmake ninja-build libvulkan1 python python-pip python-dev python3-dev python3-pip libpng16-dev libtiff5-dev libjpeg-dev tzdata sed curl unzip autoconf libtool rsync libxml2-dev git
```

__All Ubuntu systems__.
Expand Down
4 changes: 2 additions & 2 deletions Examples/CppClient/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ BINDIR=$(CURDIR)/bin
INSTALLDIR=$(CURDIR)/libcarla-install
TOOLCHAIN=$(CURDIR)/ToolChain.cmake

CC=/usr/bin/gcc-7
CXX=/usr/bin/g++-7
CC=/usr/bin/gcc
CXX=/usr/bin/g++
CXXFLAGS=-std=c++14 -pthread -fPIC -O3 -DNDEBUG -Werror -Wall -Wextra

define log
Expand Down
8 changes: 4 additions & 4 deletions LibCarla/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ project(libcarla)
option(LIBCARLA_BUILD_DEBUG "Build debug configuration" ON)
option(LIBCARLA_BUILD_RELEASE "Build release configuration" ON)
option(LIBCARLA_BUILD_TEST "Build unit tests" ON)
option(LIBCARLA_USE_ROS "Build ROS variant" OFF)

message(STATUS "Build debug: ${LIBCARLA_BUILD_DEBUG}")
message(STATUS "Build release: ${LIBCARLA_BUILD_RELEASE}")
message(STATUS "Build test: ${LIBCARLA_BUILD_TEST}")
message(STATUS "Enable ROS: ${LIBCARLA_USE_ROS}")

set(libcarla_source_path "${PROJECT_SOURCE_DIR}/../source")
set(libcarla_source_thirdparty_path "${libcarla_source_path}/third-party")
Expand All @@ -24,14 +26,12 @@ if (CMAKE_BUILD_TYPE STREQUAL "Client")
elseif (CMAKE_BUILD_TYPE STREQUAL "Server")
add_subdirectory("server")
elseif (CMAKE_BUILD_TYPE STREQUAL "Pytorch")
add_subdirectory("pytorch")
elseif (CMAKE_BUILD_TYPE STREQUAL "ros2")
add_subdirectory("fast_dds")
add_subdirectory("pytorch")
else ()
message(FATAL_ERROR "Unknown build type '${CMAKE_BUILD_TYPE}'")
endif ()

# GTest is not compiled on Windows.
if ((LIBCARLA_BUILD_TEST) AND (NOT WIN32) AND (NOT (CMAKE_BUILD_TYPE STREQUAL "Pytorch")) AND (NOT (CMAKE_BUILD_TYPE STREQUAL "ros2")))
if ((LIBCARLA_BUILD_TEST) AND (NOT WIN32) AND (NOT (CMAKE_BUILD_TYPE STREQUAL "Pytorch")))
add_subdirectory("test")
endif()
6 changes: 0 additions & 6 deletions LibCarla/cmake/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,6 @@ file(GLOB libcarla_carla_trafficmanager_sources
set(libcarla_sources "${libcarla_sources};${libcarla_carla_trafficmanager_sources}")
install(FILES ${libcarla_carla_trafficmanager_sources} DESTINATION include/carla/trafficmanager)

file(GLOB libcarla_carla_ros2_sources
"${libcarla_source_path}/carla/ros2/*.cpp"
"${libcarla_source_path}/carla/ros2/*.h")
set(libcarla_sources "${libcarla_sources};${libcarla_carla_ros2_sources}")
install(FILES ${libcarla_carla_ros2_sources} DESTINATION include/carla/ros2)

# ==============================================================================
# Create targets for debug and release in the same build type.
# ==============================================================================
Expand Down
56 changes: 0 additions & 56 deletions LibCarla/cmake/fast_dds/CMakeLists.txt

This file was deleted.

61 changes: 44 additions & 17 deletions LibCarla/cmake/server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
cmake_minimum_required(VERSION 3.5.1)
project(libcarla-server)

# Install libc++ shared libraries.
file(GLOB LibCXX_Libraries "${LLVM_LIB_PATH}/libc++*")
install(FILES ${LibCXX_Libraries} DESTINATION lib)

# Install rpclib.
install(DIRECTORY "${RPCLIB_INCLUDE_PATH}/rpc" DESTINATION include)
file(GLOB libcarla_carla_rpclib "${RPCLIB_LIB_PATH}/*.*")
install(FILES ${libcarla_carla_rpclib} DESTINATION lib)

# Install headers.

install(DIRECTORY "${libcarla_source_path}/compiler" DESTINATION include)

file(GLOB libcarla_carla_headers "${libcarla_source_path}/carla/*.h")
Expand Down Expand Up @@ -71,8 +60,19 @@ install(FILES ${libcarla_carla_streaming_low_level_headers} DESTINATION include/
file(GLOB libcarla_carla_multigpu_headers "${libcarla_source_path}/carla/multigpu/*.h")
install(FILES ${libcarla_carla_multigpu_headers} DESTINATION include/carla/multigpu)

file(GLOB libcarla_carla_ros2_headers "${libcarla_source_path}/carla/ros2/*.h")
install(FILES ${libcarla_carla_ros2_headers} DESTINATION include/carla/ros2)
if (LIBCARLA_USE_ROS)
# only install the required public interface headers
foreach(dir "/" "/types/" )
file(GLOB libcarla_carla_ros2_public_headers
"${libcarla_source_path}/carla/ros2${dir}*.h"
)
install(FILES ${libcarla_carla_ros2_public_headers} DESTINATION include/carla/ros2${dir})
endforeach()

if(NOT WIN32)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3" CACHE STRING "" FORCE)
endif()
endif()

install(DIRECTORY "${BOOST_INCLUDE_PATH}/boost" DESTINATION include)

Expand Down Expand Up @@ -118,22 +118,34 @@ file(GLOB libcarla_server_sources
"${libcarla_source_path}/carla/streaming/low_level/*.h"
"${libcarla_source_path}/carla/multigpu/*.h"
"${libcarla_source_path}/carla/multigpu/*.cpp"
"${libcarla_source_path}/carla/ros2/*.h"
"${libcarla_source_path}/carla/ros2/*.cpp"
"${libcarla_source_thirdparty_path}/odrSpiral/*.cpp"
"${libcarla_source_thirdparty_path}/odrSpiral/*.h"
"${libcarla_source_thirdparty_path}/moodycamel/*.cpp"
"${libcarla_source_thirdparty_path}/moodycamel/*.h"
"${libcarla_source_thirdparty_path}/pugixml/*.cpp"
"${libcarla_source_thirdparty_path}/pugixml/*.hpp")


set(libcarla_ros_sources "")
if (LIBCARLA_USE_ROS)
file(GLOB libcarla_ros_sources
"${libcarla_source_path}/carla/ros2/*.cpp"
"${libcarla_source_path}/carla/ros2/listeners/*.cpp"
"${libcarla_source_path}/carla/ros2/publishers/*.cpp"
"${libcarla_source_path}/carla/ros2/subscribers/*.cpp"
"${libcarla_source_path}/carla/ros2/types/*.cpp")
endif()

# ==============================================================================
# Create targets for debug and release in the same build type.
# ==============================================================================

if (LIBCARLA_BUILD_RELEASE)

add_library(carla_server STATIC ${libcarla_server_sources})
add_library(carla_server STATIC
${libcarla_server_sources}
${libcarla_ros_sources}
)

target_include_directories(carla_server SYSTEM PRIVATE
"${BOOST_INCLUDE_PATH}"
Expand All @@ -143,11 +155,20 @@ if (LIBCARLA_BUILD_RELEASE)

set_target_properties(carla_server PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS_RELEASE}")

if (LIBCARLA_USE_ROS)
target_include_directories(carla_server SYSTEM PRIVATE
"${FASTDDS_INCLUDE_PATH}")
target_link_directories(carla_server PRIVATE ${FASTDDS_LIB_PATH})
target_link_libraries(carla_server fastrtps fastcdr)
endif()
endif()

if (LIBCARLA_BUILD_DEBUG)

add_library(carla_server_debug STATIC ${libcarla_server_sources})
add_library(carla_server_debug STATIC
${libcarla_server_sources}
${libcarla_ros_sources}
)

target_include_directories(carla_server_debug SYSTEM PRIVATE
"${BOOST_INCLUDE_PATH}"
Expand All @@ -158,4 +179,10 @@ if (LIBCARLA_BUILD_DEBUG)
set_target_properties(carla_server_debug PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS_DEBUG}")
target_compile_definitions(carla_server_debug PUBLIC -DBOOST_ASIO_ENABLE_BUFFER_DEBUGGING)

if (LIBCARLA_USE_ROS)
target_include_directories(carla_server_debug SYSTEM PRIVATE
"${FASTDDS_INCLUDE_PATH}")
target_link_directories(carla_server_debug PRIVATE ${FASTDDS_LIB_PATH})
target_link_libraries(carla_server_debug fastrtps fastcdr)
endif()
endif()
4 changes: 4 additions & 0 deletions LibCarla/cmake/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ endif()
link_directories(
${RPCLIB_LIB_PATH}
${GTEST_LIB_PATH})
if (LIBCARLA_USE_ROS)
link_directories(${FASTDDS_LIB_PATH})
endif()


file(GLOB libcarla_test_sources
"${libcarla_source_path}/carla/profiler/*.cpp"
Expand Down
33 changes: 31 additions & 2 deletions LibCarla/source/carla/Exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
#ifdef BOOST_NO_EXCEPTIONS

namespace boost {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty space pls

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed by calling Util/Formatting/codeformat.py and placing .clang-format to LibCarla folder

void throw_exception(const std::exception &e) {
carla::throw_exception(e);
}

void throw_exception(
const std::exception &e,
boost::source_location const & loc) {
boost::source_location const & ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return back parameter name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done and added (void)loc as the second option to get rid of the compiler warning on this.

throw_exception(e);
}

Expand Down Expand Up @@ -54,4 +54,33 @@ namespace detail {
} // namespace detail
} // namespace clmdep_asio

namespace asio {
namespace detail {

template <typename Exception>
void throw_exception(const Exception& e) {
carla::throw_exception(e);
}

template void throw_exception<std::bad_cast>(const std::bad_cast &);
template void throw_exception<std::exception>(const std::exception &);
template void throw_exception<std::system_error>(const std::system_error &);

} // namespace detail
} // namespace asio

#endif // ASIO_NO_EXCEPTIONS

#ifndef LIBCARLA_NO_EXCEPTIONS

namespace carla {
template
#ifndef __clang__
// clang doesn't support C++11 attributes in template explicit instantiation, since attributes in each case cannot be changed here
// MSVC requires it (might be a bit too conservative and requires the attributes also in explicit instanciation)
[[ noreturn ]]
#endif
void throw_exception<std::exception>(const std::exception &);
}

#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EOF is missing in this file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed by calling Util/Formatting/codeformat.py and placing .clang-format to LibCarla folder

8 changes: 2 additions & 6 deletions LibCarla/source/carla/Exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@

#pragma once

#ifdef LIBCARLA_NO_EXCEPTIONS

namespace std {
#include <exception>

class exception;

} // namespace std
#ifdef LIBCARLA_NO_EXCEPTIONS

namespace carla {

Expand Down
Loading