报错信息
/usr/bin/ld: CMakeFiles/waypoint_follower2_node.dir/src/waypoint_follower2.cpp.o: in function `convertLatLongToUTM(double, double)':
waypoint_follower2.cpp:(.text+0x251): undefined reference to `GeographicLib::UTMUPS::Forward(double, double, int&, bool&, double&, double&, double&, double&, int, bool)'
/usr/bin/ld: waypoint_follower2.cpp:(.text+0x272): undefined reference to `GeographicLib::MGRS::Forward(int, bool, double, double, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
collect2: error: ld returned 1 exit status
make[2]: *** [waypoint_follower/waypoint_follower/CMakeFiles/waypoint_follower2_node.dir/build.make:106:/home/ac/catkin_ws/devel/lib/waypoint_follower/waypoint_follower2_node] 错误 1
make[1]: *** [CMakeFiles/Makefile2:22427:waypoint_follower/waypoint_follower/CMakeFiles/waypoint_follower2_node.dir/all] 错误 2
make[1]: *** 正在等待未完成的任务....
报错原因
缺失关于GeographicLib
的库文件,或者没有链接到GeographicLib
的库文件。
解决方案
- 安装robot_localization
使用ubuntu软件源进行安装:
sudo apt-get install ros-xxx-robot-localization #xxx为你的ros版本名称
或者使用源码安装:(推荐,注意xxx为ros版本名称,根据自己的版本进行修改)
mkdir -p catkin_ws/src
cd catkin_ws/src
git clone https://github.com/cra-ros-pkg/robot_localization --branch xxx-devel #(xxx为你的ros版本名称)
cd ..
catkin_make -DCMAKE_BUILD_TYPE=Release
- 链接到
GeographicLib
的库文件
在报错的功能包的CMakeLists.txt文件内进行修改如下:
# Geographiclib installs FindGeographicLib.cmake to this non-standard location
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/usr/share/cmake/geographiclib/")
find_package(GeographicLib REQUIRED)
add_executable(xxx src/xxx.cpp) #此处xxx为你所需要编译的节点,下面一行也一样
target_link_libraries(xxx ${catkin_LIBRARIES} ${GeographicLib_LIBRARIES})