/home/ubuntu/catkin_ws/src/navigation/map_server/src/main.cpp:47:30: fatal error: nav_msgs/LoadMap.h: No such file or directory compilation terminated. CMakeFiles/map_server.dir/build.make:62: recipe for target 'CMakeFiles/map_server.dir/src/main.cpp.o' failed
时间: 2023-07-24 22:07:49 浏览: 65
这个错误提示是说在编译 `map_server` 时,编译器无法找到 `nav_msgs/LoadMap.h` 这个头文件。解决方法是需要在 `CMakeLists.txt` 文件中加入依赖项,使得编译器能够找到该头文件。具体的方法是在 `CMakeLists.txt` 的 `find_package()` 函数中添加 `message_generation` 依赖项,如下所示:
```
find_package(catkin REQUIRED COMPONENTS
roscpp
tf
nav_msgs
message_generation
)
```
然后,在 `CMakeLists.txt` 的 `add_executable()` 函数中,将 `message_generation` 依赖项添加到 `target_link_libraries()` 函数的参数列表中,如下所示:
```
add_executable(map_server
src/main.cpp
)
target_link_libraries(map_server
${catkin_LIBRARIES}
${Boost_LIBRARIES}
${PCL_LIBRARIES}
${YAML_CPP_LIBRARIES}
message_generation
)
```
这样就可以让编译器找到 `nav_msgs/LoadMap.h` 头文件了。