0

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
ricber
  • 45
  • 6
  • If you have g2o library **installed**, then you should have `G2OConfig.cmake` file. If you don't have this file, then you need to **install** g2o. – Tsyvarev Oct 25 '20 at 17:19
  • If I launch the `make install` instruction I get this error `No rule to make target 'install'`. However, I see this "install" instruction in the CMakeLists file: `INSTALL(FILES ${PROJECT_BINARY_DIR}/g2o/config.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/g2o)`. I do not see any `G2OConfig.cmake` file. Just a `config.h.in` file – ricber Oct 26 '20 at 11:59
  • Actually there is not the `G2OConfig.cmake` file even in the directory of the other g2o version. – ricber Oct 26 '20 at 12:02
  • File `G2OConfig.cmake` is installed by `install` with parameters `FILES "${G2O_PROJECT_CONFIG}" "${G2O_VERSION_CONFIG}"` ([CMakeLists.txt:407](https://github.com/RainerKuemmerle/g2o/blob/master/CMakeLists.txt#L407)). – Tsyvarev Oct 26 '20 at 14:52
  • So why there is not that file when I launch `make`? – ricber Oct 27 '20 at 11:18
  • Please, show your steps for building and installing g2o library. – Tsyvarev Oct 27 '20 at 11:20
  • I added **EDIT 2** to the question – ricber Oct 29 '20 at 16:21
  • `make` just **builds** the library. **Installation** is performed with `make install`. – Tsyvarev Oct 29 '20 at 16:48
  • If I launch the `make install` instruction I get this error `No rule to make target 'install'`. – ricber Oct 31 '20 at 10:17

0 Answers0