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之旅

目录
相关文章
|
6月前
|
iOS开发
部分库不支持32位系统archive报错:Undefined symbols for architecture armv7
部分库不支持32位系统archive报错:Undefined symbols for architecture armv7
49 0
|
6月前
|
Swift
swift相关项目包含私有库引起的Undefined symbols for architecture arm64
swift相关项目包含私有库引起的Undefined symbols for architecture arm64
65 0
|
Linux C语言 计算机视觉
OpenIN2 Linux 编译OpenCV 报错undefined reference to `xxx@xxx‘
OpenIN2 Linux 编译OpenCV 报错undefined reference to `xxx@xxx‘
322 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
143 0
undefined reference to `major‘
undefined reference to `major‘
276 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‘
93 0
|
C++
undefined reference to `vtable for XXX‘
undefined reference to `vtable for XXX‘
178 0
NDK编译doubango时出现错误:undefined reference to ‘stderr‘
NDK编译doubango时出现错误:undefined reference to ‘stderr‘
136 0
|
计算机视觉
交叉编译opencv:undefined reference to `png_riffle_palette_neon
交叉编译opencv:undefined reference to `png_riffle_palette_neon
195 0
undefined reference to `crypto_get_random'
undefined reference to `crypto_get_random'
83 0

热门文章

最新文章