Visual slam Lesson 6: curve fitting with g2o, error: cmake error at CMakeList.txt (find_ package) By not providing“FindG2O.cmake“

When compiling with KDevelop, my CMakeList.txt There’s an error in the file. It’s mine CMakeList.txt The code in the file is as follows:

the errors are as follows:

The solution is as follows:
you need to CMakeList.txt Modify the following code in the file:
1. First of all, you need to find the location of your g2o installation: find the g2o folder – right click the properties to see

Add


list (APPEND CMAKE_ MODULE_ PATH ${PROJECT_ SOURCE_ DIR}/cmake)


Amend to read

list(APPEND CMAKE_ MODULE_ Path/home/fan/desktop/g2o master/cmake_ modules)

Among them,

/Home/fan/desktop/g2o master/cmake_ Modules// where to install your own g2o files

2. Add an extra set

set(G2O_ ROOT /usr/local/include/g2o)

After completing the above steps, there will be no problem with the build and it can be executed smoothly.
The code is as follows

cmake_ minimum_ required(VERSION 2.8)
project(go)
set(CMAKE_ BUILD_ TYPE Release)
set(CMAKE_ CXX_ FLAGS “-std=c++14 -O3”)
list(APPEND CMAKE_ MODULE_ Path/home/fan/desktop/g2o master/cmake_ modules)
set(G2O_ ROOT /usr/local/include/g2o)

find_ package(OpenCV REQUIRED)
include_ directories(${OpenCV_ INCLUDE_ DIRS})

find_ package(G2O REQUIRED)
include_ directories(${G2O_ INCLUDE_ DIRS})

include_ directories(“/usr/include/eigen3”)

add_ executable(go main.cpp )
target_ link_ libraries(go ${OpenCV_ LIBS} ${G2O_ CORE_ LIBRARY} ${G2O_ STUFF_ LIBRARY})

Read More: