1. Problem description
When I followed the fourth lecture of the second edition of "Visual slam 14 Lectures" to learn to use the sophus library, I always reported fatal error and failed to compile when making, so I recorded this installation process.
2. Installation steps
1. Install the eigen library
The use of sophus must rely on the eigen library, so download eigen first, but if you have a version of eigen below 3.3, please uninstall it first.
1.1 Judging that there is an old version
sudo updatedb
locate eigen3
1.2 Check the installed eigen version
pkg-config --modversion eigen3
1.3 Uninstall the old version of eigen
sudo rm -rf /usr/include/eigen3 /usr/lib/cmake/eigen3 /usr/share/doc/libeigen3-dev /usr/share/pkgconfig/eigen3.pc /var/lib/dpkg/info/libeigen3-dev.list /var/lib/dpkg/info/libeigen3-dev.md5sums
1.4 eigen 3.3.7 version installation
(1 ) Download the installation package from the official website: eigen-3.3.7.tar.bz2, and then extract it here
(2) Enter the folder eigen-3.3.7, right-click to open it in the terminal.
(3) Install
mkdir build
cd build
cmake ..
sudo make install
PS: sudo apt-get install libeigen3-dev
This command may install and download the 3.2 version of eigen, which cannot match the sophus of the template class, so this method is not recommended for installation.
2. Install the fmt library
Currently, sophus needs to rely on the fmt library, so fmt should be installed first:
git clone https://github.com/fmtlib/fmt.git
cd fmt
mkdir build
cd build
cmake ..
make
sudo make install
PS: download link
- Baidu network disk link Extraction code: aw6g
- CSDN resource download
3. Install the Sophus library
3.1 Installation
git clone https://github.com/strasdat/Sophus.git
cd Sophus/
mkdir build
cd build
cmake ..
make
sudo make install
PS:
- Many tutorials on the Internet have rollbacks, that is
git checkout a621ff
, this will pretend to be the old version of non-template sophus, while the new version of sophus uses template classes; sudo make install
Must have.
3.2 Testing
Re-make, successfully compiled:
the following figure is a screenshot of the successful operation.
4. slam_14 talks about error
4.1 error description
An error occurred when ch4/example/trajectoryError
evaluating : "undefined reference to `fmt::v8::detail::assert_fail(char const*, int, char const*)’", compilation failed.
4.2 Problem Solving
Modify the two files CMakeLists.txt and trajectoryError.cpp . The specific modifications are as follows:
ch4/example/CMakeLists.txt
Add the following to the text :
find_package(Sophus REQUIRED)
target_link_libraries(trajectoryError Sophus::Sophus)
- Modify the text as
ch4/example/trajectoryError.cpp
follows:
// string groundtruth_file = "./groundtruth.txt";
// string estimated_file = "./estimated.txt";
string groundtruth_file = "../groundtruth.txt";
string estimated_file = "../estimated.txt";
4.3 Test results
Recompile make and run successfully: