g2o库出现undefined reference to错误

简介: 笔记

g2o库出现undefined reference to错误


1.我的CMkeLists.txt

cmake_minimum_required(VERSION 2.6)
project(g2o_learn)
set(CMAKE_CXX_FLAGS "-std=c++11")
include_directories("/usr/include/eigen3")
find_package(g2o REQUIRED)
include_directories(${g2o_INCLUDE_DIRS})
find_package( OpenCV REQUIRED )                          
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(g2o_learn main.cpp)
target_link_libraries( g2o_learn ${OpenCV_LIBRARIES}) 
target_link_libraries(g2o_learn ${g2o_LIBRARIES})
install(TARGETS g2o_learn RUNTIME DESTINATION bin)

在这之后,编译程序的时候,出现undefined reference to错误,基本上所有的g2o的模块都找不到,

解决方法如下

1. 找到下载g2o库的文件夹下,进入cmake_modules文件夹下,找到FINDG2O.cmake,然后复制到cpp目录下的cmake文件夹下,然后修改CMakeList.txt文件,修改后的文件内容如下

cmake_minimum_required(VERSION 2.6)
project(g2o_learn)
set(CMAKE_CXX_FLAGS "-std=c++11")
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include_directories("/usr/include/eigen3")
find_package(g2o REQUIRED)
include_directories(${g2o_INCLUDE_DIRS})
find_package( OpenCV REQUIRED )                          
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(g2o_learn main.cpp)
target_link_libraries( g2o_learn ${OpenCV_LIBRARIES}) 
#target_link_libraries(g2o_learn ${g2o_LIBRARIES})
target_link_libraries(g2o_learn g2o_core g2o_stuff)
install(TARGETS g2o_learn RUNTIME DESTINATION bin)

Thank for your reading !!!

公众号:FPGA之旅

目录
相关文章
|
7月前
|
iOS开发
部分库不支持32位系统archive报错:Undefined symbols for architecture armv7
部分库不支持32位系统archive报错:Undefined symbols for architecture armv7
66 0
|
7月前
|
Swift
swift相关项目包含私有库引起的Undefined symbols for architecture arm64
swift相关项目包含私有库引起的Undefined symbols for architecture arm64
102 0
|
Linux C语言 计算机视觉
OpenIN2 Linux 编译OpenCV 报错undefined reference to `xxx@xxx‘
OpenIN2 Linux 编译OpenCV 报错undefined reference to `xxx@xxx‘
342 0
OpenIN2 Linux 编译OpenCV 报错undefined reference to `xxx@xxx‘
|
Ubuntu C语言
【ubuntu】2.c:(.text+0xd2): undefined reference to `pthread_create‘ collect2: error: ld returned
【ubuntu】2.c:(.text+0xd2): undefined reference to `pthread_create‘ collect2: error: ld returned
148 0
undefined reference to `major‘
undefined reference to `major‘
281 0
undefined reference to `gdk_monitor_get_scale_factor/gtk_widget_get_scale_factor‘
undefined reference to `gdk_monitor_get_scale_factor/gtk_widget_get_scale_factor‘
96 0
|
C++
undefined reference to `vtable for XXX‘
undefined reference to `vtable for XXX‘
186 0
NDK编译doubango时出现错误:undefined reference to ‘stderr‘
NDK编译doubango时出现错误:undefined reference to ‘stderr‘
140 0
|
计算机视觉
交叉编译opencv:undefined reference to `png_riffle_palette_neon
交叉编译opencv:undefined reference to `png_riffle_palette_neon
208 0
undefined reference to `crypto_get_random'
undefined reference to `crypto_get_random'
87 0