从github中下载源码后,按照readme一步步来,安装完各种依赖后,直接运行了build.sh。
需要注意的是,之前在14.04中安装完依赖后,cmake报错。根据错误信息锁定为cmake版本低,于是重装了cmake 3.9,成功编译。后来系统重装为16.04,为了以防万一,我直接重装了cmake。
在运行Example阶段,遇到了错误如下:
Loading ORB Vocabulary. This could take a while...
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
./rgbd_pcl.bash: line 2: 8338 Aborted (core dumped) ./Examples/RGB-D/rgbd_tum Vocabulary/ORBvoc.bin Examples/RGB-D/TUM1.yaml ~/Downloads/dataset/rgbd_dataset_freiburg3_long_office_household_validation/ Examples/RGB-D/associations/fr3_office_val.txt
这里是内存溢出的错误。打开监视器,重新编译了一下,再运行:
Loading ORB Vocabulary. This could take a while...
Vocabulary loading failure: This is not a correct text file!
Wrong path to vocabulary.
Falied to open at: Vocabulary/ORBvoc.bin
经过检查,发现我运行的脚本中把ORBvoc.txt写成了ORBvoc.bin。更正后继续:
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /home/zhao/Downloads/opencv-2.4.11/modules/highgui/src/window.cpp, line 483
terminate called after throwing an instance of 'cv::Exception'
what(): /home/zhao/Downloads/opencv-2.4.11/modules/highgui/src/window.cpp:483: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvNamedWindow
提示安装libgtk2.0-dev pkg-config,并重新安装opencv。
然后成功运行~~
——————————————————————
31.8.2017 更新
——————————————————————
在原生ORBSLAM2可以运行后,尝试运行高博的ORBSLAM2_with_pointcloud_map-master,结果编译时出现了如下问题:
make[2]: *** No rule to make target '/usr/lib/x86_64-linux-gnu/libproj.so', needed by '../lib/libORB_SLAM2.so'. Stop.
CMakeFiles/Makefile2:178: recipe for target 'CMakeFiles/ORB_SLAM2.dir/all' failed
make[1]: *** [CMakeFiles/ORB_SLAM2.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
查了很多资料,包括重装pcl,opencv,都不行,并且把系统也弄的乱七八糟,于是最后重装系统。
结果重新编译原生ORBSLAM2时,依旧出现了
make[2]: *** No rule to make target '/usr/lib/x86_64-linux-gnu/libtiff.so', needed by '../lib/libORB_SLAM2.so'. Stop.
CMakeFiles/Makefile2:178: recipe for target 'CMakeFiles/ORB_SLAM2.dir/all' failed
make[1]: *** [CMakeFiles/ORB_SLAM2.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
可见虽然一个是libproj.so,一个是libtiff.so,问题都大同小异。
定位到/usr/lib/x86_64-linux-gnu文件夹后,发现存在一个libtiff.so.5,并没有libtiff.so。而ubuntu16.04在安装的时候是包括了libtiff5的。
所以尝试讲两个文件进行软连接,输入
sudo ln -s /usr/lib/x86_64-linux-gnu/libtiff.so.5 /usr/lib/x86_64-linux-gnu/libtiff.so
问题解决!