I have two versions of the same library (g2o) on my Ubuntu 18.04 pc. One is built with catkin_make
in a ROS workspace (/home/riccardo/catkin_ws/src/g2o).
The other one is in the directory of the project I'm trying to build (/home/myproject/g2o).
As I said, I'm trying to build myproject with catkin_build
, and this second version of the g2o library. However, I see that catkin_build
finds the first version of the g2o library, the one in the ROS workspace.
I have a CMakeLists.txt under the myproject directory and I tried different ways to specify the exact package location:
- First, I tried with:
find_package(G2O REQUIRED PATHS ${PROJECT_SOURCE_DIR}/g2o)
In this case the error is the following:
CMake Error at /home/myproject/CMakeLists.txt:28 (find_package):
Could not find a package configuration file provided by "G2O" with any of
the following names:
G2OConfig.cmake
g2o-config.cmake
Add the installation prefix of "G2O" to CMAKE_PREFIX_PATH or set "G2O_DIR"
to a directory containing one of the above files. If "G2O" provides a
separate development package or SDK, be sure it has been installed.
- Then, I also tried with:
LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/g2o/cmake_modules)
SET(G2O_ROOT ${PROJECT_SOURCE_DIR}/g2o)
find_package(G2O REQUIRED)
And in this case the other g2o version was used.
Can you help me please?
EDIT 1
I think there is a related question on Stackoverflow:
How to clone, build, and link g2o framework in C++
However I do not have the directory specified by ${CMAKE_PREFIX_INTALL}
in /home/user/ . I do not understand what I have to do...
EDIT 2
For building and installing the g2o library I launched the following commands in the g2o root directory:
- mkdir build
- cd build
- cmake ../
- make