# Livox ROS2驱动编译报ament_auto错误及构建脚本参数修正

> 原文链接：https://robotics.hellobike.com/pitfalls/2025-12-03-livox-ros-driver2-205
> 频道：pitfalls | 更新日期：2025-12-03 | 标签：auto, github-issue, livox_ros_driver2
> 核心摘要：编译Livox ROS2驱动报错ament_auto缺失，需补装ros-foxy-ament-cmake-auto或改用ROS1后缀构建。

# Livox ROS2驱动编译报ament_auto错误及构建脚本参数修正

::: v-pre
> 本文由 AI 根据公开内容整理，可能有误，请以原文为准：[Building the package throws error with ament_auto even though ament_auto is installed](https://github.com/Livox-SDK/livox_ros_driver2/issues/205)（GitHub Livox-SDK/livox_ros_driver2 #205）

**状态**：有绕过办法

## 问题

在ROS Foxy环境下执行`./build.sh ROS2`编译livox_ros_driver2时，即使已安装ament_auto仍抛出构建错误。社区反馈指出可能缺少特定Debian依赖包，或构建脚本参数使用不当导致环境配置异常。

## 环境

ROS Foxy, livox_ros_driver2, Ubuntu Linux

## 解决办法

1. 检查并安装缺失的CMake自动构建依赖：`sudo apt install ros-foxy-ament-cmake-auto`。
2. 若ROS2环境持续报错，尝试切换构建目标为ROS1版本：执行`./build.sh ROS1`（注意后缀区分大小写）。
3. 重新source环境后再次编译：`source /opt/ros/foxy/setup.sh && ./build.sh ROS2`。

讨论原作者：@MeghaMaheshwari 等，版权归原作者所有。
:::

## 原始参考来源 (Sources)

- [GitHub Livox-SDK/livox_ros_driver2 #205：Building the package throws error with ament_auto even though ament_auto is installed](https://github.com/Livox-SDK/livox_ros_driver2/issues/205)