VINS-Mono安装问题总结

1 can not be used when making a shared object; recompile with -fPIC

[ 30%] Built target vins_estimator
/usr/bin/ld: /usr/local/lib/libgflags.a(gflags.cc.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libgflags.a: 无法添加符号: 错误的值
collect2: error: ld returned 1 exit status
VINS-Mono/camera_model/CMakeFiles/camera_model.dir/build.make:450: recipe for target '/home/windistance/catkin_ws/devel/lib/libcamera_model.so' failed
make[2]: *** [/home/windistance/catkin_ws/devel/lib/libcamera_model.so] Error 1
CMakeFiles/Makefile2:1954: recipe for target 'VINS-Mono/camera_model/CMakeFiles/camera_model.dir/all' failed
make[1]: *** [VINS-Mono/camera_model/CMakeFiles/camera_model.dir/all] Error 2
make[1]: *** 正在等待未完成的任务....

解决方法:

这里提示gflags库的libgflags.a: 无法添加符号: 错误的值,需要重新编译,在gflags的CMakeLists中添加:

add_compile_options(-fPIC)

或者

set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_FLAGS "-std=c++11")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fPIC")

或者直接通过apt安装编译好的环境

sudo apt-get install libgflags-dev libgoogle-glog-dev

2 对‘cv::Mat::updateContinuityFlag()’未定义的引用

[ 40%] Built target camera_model
Scanning dependencies of target ar_demo_node
CMakeFiles/Calibration.dir/src/calib/CameraCalibration.cc.o:在函数‘camodocal::CameraCalibration::optimize(boost::shared_ptr<camodocal::Camera>&, std::vector<cv::Mat, std::allocator<cv::Mat> >&, std::vector<cv::Mat, std::allocator<cv::Mat> >&) const’中:
CameraCalibration.cc:(.text+0x3a72):对‘cv::Mat::updateContinuityFlag()’未定义的引用
CameraCalibration.cc:(.text+0x4d45):对‘cv::Mat::updateContinuityFlag()’未定义的引用
CMakeFiles/Calibration.dir/src/camera_models/PinholeCamera.cc.o:在函数‘camodocal::PinholeCamera::initUndistortRectifyMap(cv::Mat&, cv::Mat&, float, float, cv::Size_<int>, float, float, cv::Mat) const’中:
PinholeCamera.cc:(.text+0x985):对‘cv::Mat::updateContinuityFlag()’未定义的引用
PinholeCamera.cc:(.text+0x16fa):对‘cv::Mat::updateContinuityFlag()’未定义的引用
CMakeFiles/Calibration.dir/src/camera_models/CataCamera.cc.o:在函数‘camodocal::CataCamera::initUndistortRectifyMap(cv::Mat&, cv::Mat&, float, float, cv::Size_<int>, float, float, cv::Mat) const’中:
CataCamera.cc:(.text+0xb9f):对‘cv::Mat::updateContinuityFlag()’未定义的引用
CMakeFiles/Calibration.dir/src/camera_models/CataCamera.cc.o:CataCamera.cc:(.text+0x168f): 跟着更多未定义的参考到 cv::Mat::updateContinuityFlag()
[ 41%] Building CXX object VINS-Mono/ar_demo/CMakeFiles/ar_demo_node.dir/src/ar_demo_node.cpp.o

解决方法:

cv::Mat::updateContinuityFlag()opencv 3.4.2及其最新版本中存在,但是我之前安装的是opencv3.4.6,所以是ros自带的opencv2.4.9冲突了,改一下camera_model/CMakeLists文件

find_package(OpenCV 3.4.6 REQUIRED)

你可能感兴趣的:(linux,ros,异常处理,opencv,SLAM)