Posted by @cwrx777:
Hi,
In the latest instructions to perform colcon build, there are additionals steps to be done:
cd ~/rmf_ws
source /opt/ros/humble/setup.bash
export CXX=clang++
export CC=clang
colcon build --mixin release lld
If i need to build selective packages, what kind of package require the above steps and when can we use the usual colcon build
command?
- packages containing building yaml e.g. rmf_demo_maps packages
- ament_python packages?
Chosen answer
Answer chosen by @cwrx777 at 2022-09-18T07:20:01Z.
Answered by @aaronchongth:
We found that the linker has issues when the packages are built using gcc
(the default), using clang
resolves that problem, but we may observe the state of gcc
if this issue gets resolved down the road before reverting back to gcc
.
In the meantime, you can add export CXX=clang++; export CC=clang;
in your ~/.bashrc
so that you build with clang
all the time without invoking the exports.
As for the mixins
, lld
is required for compiling with clang
, while release
replaces the longer invocation of --cmake-args -DCMAKE_BUILD_TYPE=Release
, you can leave it out but you would miss out on the optimizations the compiler provides.
clang
related commands will affect any package that has C++ compilation happening, so if you’re just compiling rmf_demos_maps
, I believe you will not need lld
or release
.
One trick you can do to save time, would be adding an alias in your ~/.bashrc
, for example,
alias cb="colcon build --mixin release lld`
This will allow you to do something like cb --packages-select rmf_demos_maps
without having to type all that. Remember to source your ~/.bashrc
again after adding the alias.