ubuntu18.04 安装g2o_viewer,遇到的所有坑和解决方法
Posted 振华OPPO
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ubuntu18.04 安装g2o_viewer,遇到的所有坑和解决方法相关的知识,希望对你有一定的参考价值。
踩坑1 |
---|
cmake时报错: Could NOT find QGLVIEWER (missing: QGLVIEWER_LIBRARY) |
1、可以安装需要的qt4依赖库,再次cmake如果解决则不需要往下看:
sudo apt-get install libqt4-dev
sudo apt-get install libqglviewer-dev-qt4
sudo apt-get install libsuitesparse-dev
2、安装需要的qt5依赖库,qt4依赖库可删可不删,两者可以共存:
sudo apt-get install libqt5-dev
sudo apt-get install libqglviewer-dev-qt5
sudo apt-get install libsuitesparse-dev
3、接着修改g2o/cmake_modules里面的 FindQGLViewer.cmake文件,让cmake能够找到它。就是在find_library(QGLVIEWER_LIBRARY_RELEASE)和find_library(QGLVIEWER_LIBRARY_DEBUG)中添加下QGLViewer-qt5:
# Need to find both Qt4,5 and QGLViewer if the QQL support is to be built
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtXml QtOpenGL QtGui)
IF(NOT Qt4_FOUND)
FIND_PACKAGE(Qt5 QUIET COMPONENTS Core Xml OpenGL Gui Widgets)
IF(NOT Qt4_FOUND AND NOT Qt5_FOUND)
MESSAGE("Qt4,5 not found. Install it and set Qt4,5_DIR accordingly")
IF (WIN32)
MESSAGE(" In Windows, Qt5_DIR should be something like C:/Qt/5.4/msvc2013_64_opengl/lib/cmake/Qt5")
ENDIF()
ENDIF()
ENDIF()
FIND_PATH(QGLVIEWER_INCLUDE_DIR qglviewer.h
/usr/include/QGLViewer
/opt/local/include/QGLViewer
/usr/local/include/QGLViewer
/sw/include/QGLViewer
ENV QGLVIEWERROOT
)
find_library(QGLVIEWER_LIBRARY_RELEASE
NAMES qglviewer-qt4 qglviewer QGLViewer QGLViewer2 QGLViewer-qt5
PATHS /usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
ENV QGLVIEWERROOT
ENV LD_LIBRARY_PATH
ENV LIBRARY_PATH
PATH_SUFFIXES QGLViewer QGLViewer/release
)
find_library(QGLVIEWER_LIBRARY_DEBUG
NAMES dqglviewer dQGLViewer dQGLViewer2 QGLViewerd2 QGLViewer-qt5
PATHS /usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
ENV QGLVIEWERROOT
ENV LD_LIBRARY_PATH
ENV LIBRARY_PATH
PATH_SUFFIXES QGLViewer QGLViewer/release
)
if(QGLVIEWER_LIBRARY_RELEASE)
if(QGLVIEWER_LIBRARY_DEBUG)
set(QGLVIEWER_LIBRARY optimized $QGLVIEWER_LIBRARY_RELEASE debug $QGLVIEWER_LIBRARY_DEBUG)
else()
set(QGLVIEWER_LIBRARY $QGLVIEWER_LIBRARY_RELEASE)
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(QGLVIEWER DEFAULT_MSG
QGLVIEWER_INCLUDE_DIR QGLVIEWER_LIBRARY)
4、重新cmake,这次不会报错了,显示-- Found QGLVIEWER: /usr/include/QGLViewer
踩坑2 |
---|
g2o_viewer: error while loading shared libraries: libg2o_viewer.so: cannot open shared object file: No such file or directory |
1、sudo gedit /etc/ld.so.conf
打开配置文件,在新的一行加上include /usr/local/lib
,保存退出。
2、然后输入sudo ldconfig
回车使配置生效。
3、终端输入g2o_viewer
,应该可以成功打开g2o_viewer的窗口。
踩坑3 |
---|
运行g2o_viewer时显示realloc(): invalid pointer 已放弃 (核心已转储) |
1、修改g2o/cmake_modules里面的 FindQGLViewer.cmake文件,加粗的就是添加的内容:
find_library(QGLVIEWER_LIBRARY_RELEASE
NAMES qglviewer-qt4 QGLViewer-qt4 qglviewer QGLViewer QGLViewer2
2、将g2o删除干净,即删除它的头文件、库文件以及可执行文件:
sudo rm -r /usr/local/include/g2o /usr/local/lib/libg2o* /usr/local/bin/g2o*
3、删除源代码中的build文件夹,然后重新编译安装g2o:
mkdir build
cd build
cmake ..
make
sudo make install
4、终端任意位置输入g2o_viewer
,即可打开g2o_viewer程序:
5、File——>Load——>result.g2o,打开如图:
参考文献
https://blog.csdn.net/qq_42995327/article/details/118681435
https://www.freesion.com/article/73111375902/
https://www.manongdao.com/article-979898.html
以上是关于ubuntu18.04 安装g2o_viewer,遇到的所有坑和解决方法的主要内容,如果未能解决你的问题,请参考以下文章