输入:
catkin build -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8
或
catkin build airsim_tutorial_pkgs -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8
报错如下:

可能是缺少 yaml-cpp 文件,然后操作:
sudo apt-get install yaml-cpp
sudo apt-get install ros-noetic-yaml
报错

编译:
catkin build airsim_tutorial_pkgs -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8
报错

根据下面的错误,用 VScode 打开报错的文件

打开文件命令:
cd /home/leaf/AirSim/ros/src/airsim_ros_pkgs
code .
yaml-cpp 没有链接到 airsim_ros

文件前面 fine_package 没有 find yaml-cpp,加上
这里不能在 find_package(catkin REQUIRED COMPONENTS 里面加入 yaml-cpp,因为这个里面是 find ros 包的,而 yaml-cpp 不是一个 ros 包,是系统的,只能单独写一个 find_packages,加入 yaml-cpp

再编译依旧报错

然后去网上下载 yaml-cpp
git clone 下来后直接安装到系统里
参考链接:
yaml-cpp的安装及使用_yaml cpp安装-CSDN博客
git clone https://github.com/jbeder/yaml-cpp.git
cd yaml-cpp
mkdir build && cd build
cmake ..
make -j16
sudo make install


再编译就成功了
catkin build airsim_tutorial_pkgs -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8
