Ubuntu16.04编译VIORB过程中遇到的问题 尤其是rosbag的问题

下面的链接是非常非常有用的,很详尽,笔芯博主。

https://blog.csdn.net/Amazingren/article/details/82357179 

尤其是解决了我关于rosbag报错的问题,undefined reference to XXX 

看到这些报错我也很头大很生气很生气,以前跑得贼溜的代码也不能make了,打击:

Scanning dependencies of target VIO
[ 66%] Building CXX object CMakeFiles/VIO.dir/src/MsgSync/MsgSynchronizer.cpp.o
[ 66%] Building CXX object CMakeFiles/VIO.dir/src/ros_vio.cc.o
[100%] Linking CXX executable ../VIO
CMakeFiles/VIO.dir/src/ros_vio.cc.o: In function `bool rosbag::Bag::readField<unsigned int>(std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&, std::string const&, bool, unsigned int*) const':
ros_vio.cc:(.text._ZN3ros27SubscriptionCallbackHelperTIRKN5boost10shared_ptrIKN11sensor_msgs4Imu_ISaIvEEEEEvE11deserializeERKNS_43SubscriptionCallbackHelperDeserializeParamsE[_ZN3ros27SubscriptionCallbackHelperTIRKN5boost10shared_ptrIKN11sensor_msgs4Imu_ISaIvEEEEEvE11deserializeERKNS_43SubscriptionCallbackHelperDeserializeParamsE]+0x6f7): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)'
CMakeFiles/VIO.dir/src/ros_vio.cc.o: In function `boost::shared_ptr<sensor_msgs::Imu_<std::allocator<void> > > rosbag::Bag::instantiateBuffer<sensor_msgs::Imu_<std::allocator<void> > >(rosbag::IndexEntry const&) const':
ag3Bag17instantiateBufferIN11sensor_msgs4Imu_ISaIvEEEEEN5boost10shared_ptrIT_EERKNS_10IndexEntryE[_ZNK6rosbag3Bag17instantiateBufferIN11sensor_msgs4Imu_ISaIvEEEEEN5boost10shared_ptrIT_EERKNS_10IndexEntryE]+0x3df): undefined reference to `rosbag::Bag::readField(std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&, std::string const&, bool, std::string&) const'
CMakeFiles/VIO.dir/src/ros_vio.cc.o: In function `boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > > rosbag::Bag::instantiateBuffer<sensor_msgs::Image_<std::allocator<void> > >(rosbag::IndexEntry const&) const':
ros_vio.cc:(.text._ZNK6rosbag3Bag17instantiateBufferIN11sensor_msgs6Image_ISaIvEEEEEN5boost10shared_ptrIT_EERKNS_10IndexEntryE[_ZNK6rosbag3Bag17instantiateBufferIN11sensor_msgs6Image_ISaIvEEEEEN5boost10shared_ptrIT_EERKNS_10IndexEntryE]+0x3df): more undefined references to `rosbag::Bag::readField(std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&, std::string const&, bool, std::string&) const' follow
CMakeFiles/VIO.dir/src/ros_vio.cc.o: In function `main':
ros_vio.cc:(.text.startup+0x5f): undefined reference to `ros::init(int&, char**, std::string const&, unsigned int)'
ros_vio.cc:(.text.startup+0x216): undefined reference to `ros::NodeHandle::NodeHandle(std::string const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&)'
collect2: error: ld returned 1 exit status
CMakeFiles/VIO.dir/build.make:268: recipe for target '../VIO' failed
make[2]: *** [../VIO] Error 1
CMakeFiles/Makefile2:163: recipe for target 'CMakeFiles/VIO.dir/all' failed
make[1]: *** [CMakeFiles/VIO.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

Launch file in Examples/ROS/ORB_VIO/launch.

以至于看到make到66就会内心颤抖,就知道卡死了。。。

之前ubuntu16.04的g++和gcc版本是5.4.0,为了配合matlab编程,将其降到啦4.9,导致了后来make不成功的问题,

将其版本升级:

sudo apt-get remove gcc

sudo apt-get install gcc

查看gcc和g++版本可使用:

gcc -v

g++ -v

输入g++的时候,系统会提示安装g++的指令,复制粘贴即可。

这之后又碰到新问题了:

Could NOT find CHOLMOD (missing:  CHOLMOD_INCLUDE_DIR CHOLMOD_LIBRARIES) 
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.

安装相关依赖项就解决问题了:

sudo apt-get install libsuitesparse-dev

现在所有的代码都能正常运行啦~。~

猜你喜欢

转载自blog.csdn.net/Pancheng1/article/details/83550506