Mastodon

Bundle Adjustment and Graph Optimization

Records on Bundle Adjustment

Issues occurred Installing g2o1 with g2o_viewer on Ubuntu 18.04


Segmentation fault(core dumped)

I met this issue right after compiling and installing the g2o on my ubuntu 18.04 machine, when I tried to run g2o_viewer

g2o_viewer

I got the error

Segmentation fault(core dumped).

After googling for a while and reading the author’s post2 on the issue page of a similar issue. I decided to use Qt5 to compile the QGLViewer library instead of the default qt4 dependencies used in directly installing libqglviewer-dev from apt.

Compile QGLViewer Library

The official page of QGLViewer is http://libqglviewer.com/, you could find detailed installation guide from the page .

For the sake of simplicity, I will only present the way to install QGLViewer tested on my Ubuntu 18.04 LTS machine.

First remove qmake of Qt4 and install Qt5

sudo apt-get remove qt4-qmake 
sudo apt-get install qt5-default qtcreator

Then download and extract the Linux version installation file from the official website

wget http://www.libqglviewer.com/src/libQGLViewer-2.7.2.tar.gz 
tar -xvf libQGLViewer-2.7.2.tar.gz && cd libQGLViewer-2.7.2

There are two ways to compile the library from source, I will only present the qmake way here, the other way could be found on the website.

qmake
make
sudo make install

After installing the QGLViewer library, go back to your g2o source code folder. And re-compile it.

cd g2o
mkdir build && cd build
cmake ..
make 
sudo make install

After compiling the g2o library, I tried to run g2o_viewer again, and I got a different error this time

g2o_viewer: error while loading shared libraries: libg2o_viewer.so: cannot open shared object file: No such file or directory

The error was so frustrating since as I checked the files in my lib folder

ls /usr/local/lib

I got libg2o_viewer.so right sitting there in the result

...
...
libg2o_viewer.so
...
...

So I decied to check if the /usr/local/lib folder was missing in my ldconfig file

sudo gedit /etc/ld.so.conf

And… it was not missing (it might be missing for you, but not for me), however, I decided to refresh my ldconfig file and give it a try.

Refresh ldconfig

sudo ldconfig

After refreshing the ldconfig file, I ran g2o_viewer again. And, Finally, it worked!

g2o_viewer
Avatar
Chengkun (Charlie) Li
Incoming PhD Student
comments powered by Disqus
Next
Previous

Related