【踩坑记录】undefined reference to `GeographicLib::UTMUPS::Forward

文章描述了在使用waypoint_follower2_node时遇到的编译错误,由于缺少GeographicLib库。提供了解决方案,包括通过apt-get安装ros-robot-localization或源码安装并手动链接GeographicLib库。
摘要由CSDN通过智能技术生成

报错信息

/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的库文件。

解决方案

  1. 安装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
  1. 链接到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})

至此解决上述报错,catkin_make编译通过。

  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值