解决error: undefined reference to g2o::OptimizableGraph::addVertex问题
解决error: undefined reference to g2o::OptimizableGraph::addVertex问题**
error: undefined reference to `g2o::OptimizableGraph::addVertex(g2o::OptimizableGraph::Vertex*, g2o::HyperGraph::Data*)’
error: undefined reference to `g2o::OptimizableGraph::addEdge(g2o::OptimizableGraph::Edge*)’
后来发现ros里面也有g2o的库,然后默认调用了ros里面的g2o。
解决方法:
修改FindG2O.cmake文件
原来的FindG2O.cmake文件为
FIND_PATH(G2O_INCLUDE_DIR g2o/core/base_vertex.h${G2O_ROOT}/include$ENV{G2O_ROOT}/include$ENV{G2O_ROOT}/usr/local/include/usr/include/opt/local/include/sw/local/include/sw/includeNO_DEFAULT_PATH)# Macro to unify finding both the debug and release versions of the
# libraries; this is adapted from the OpenSceneGraph FIND_LIBRARY
# macro.MACRO(FIND_G2O_LIBRARY MYLIBRARY MYLIBRARYNAME)FIND_LIBRARY("${MYLIBRARY}_DEBUG"NAMES "g2o_${MYLIBRARYNAME}_d"PATHS${G2O_ROOT}/lib/Debug${G2O_ROOT}/lib$ENV{G2O_ROOT}/lib/Debug$ENV{G2O_ROOT}/libNO_DEFAULT_PATH)FIND_LIBRARY("${MYLIBRARY}_DEBUG"NAMES "g2o_${MYLIBRARYNAME}_d"PATHS~/Library/Frameworks/Library/Frameworks/usr/local/lib/usr/local/lib64/usr/lib/usr/lib64/opt/local/lib/sw/local/lib/sw/lib)FIND_LIBRARY(${MYLIBRARY}NAMES "g2o_${MYLIBRARYNAME}"PATHS${G2O_ROOT}/lib/Release${G2O_ROOT}/lib$ENV{G2O_ROOT}/lib/Release$ENV{G2O_ROOT}/libNO_DEFAULT_PATH)FIND_LIBRARY(${MYLIBRARY}NAMES "g2o_${MYLIBRARYNAME}"PATHS~/Library/Frameworks/Library/Frameworks/usr/local/lib/usr/local/lib64/usr/lib/usr/lib64/opt/local/lib/sw/local/lib/sw/lib)IF(NOT ${MYLIBRARY}_DEBUG)IF(MYLIBRARY)SET(${MYLIBRARY}_DEBUG ${MYLIBRARY})ENDIF(MYLIBRARY)ENDIF( NOT ${MYLIBRARY}_DEBUG)ENDMACRO(FIND_G2O_LIBRARY LIBRARY LIBRARYNAME)# Find the core elements
FIND_G2O_LIBRARY(G2O_STUFF_LIBRARY stuff)
FIND_G2O_LIBRARY(G2O_CORE_LIBRARY core)# Find the CLI library
FIND_G2O_LIBRARY(G2O_CLI_LIBRARY cli)# Find the pluggable solvers
FIND_G2O_LIBRARY(G2O_SOLVER_CHOLMOD solver_cholmod)
FIND_G2O_LIBRARY(G2O_SOLVER_CSPARSE solver_csparse)
FIND_G2O_LIBRARY(G2O_SOLVER_CSPARSE_EXTENSION csparse_extension)
FIND_G2O_LIBRARY(G2O_SOLVER_DENSE solver_dense)
FIND_G2O_LIBRARY(G2O_SOLVER_PCG solver_pcg)
FIND_G2O_LIBRARY(G2O_SOLVER_SLAM2D_LINEAR solver_slam2d_linear)
FIND_G2O_LIBRARY(G2O_SOLVER_STRUCTURE_ONLY solver_structure_only)
FIND_G2O_LIBRARY(G2O_SOLVER_EIGEN solver_eigen)# Find the predefined types
FIND_G2O_LIBRARY(G2O_TYPES_DATA types_data)
FIND_G2O_LIBRARY(G2O_TYPES_ICP types_icp)
FIND_G2O_LIBRARY(G2O_TYPES_SBA types_sba)
FIND_G2O_LIBRARY(G2O_TYPES_SCLAM2D types_sclam2d)
FIND_G2O_LIBRARY(G2O_TYPES_SIM3 types_sim3)
FIND_G2O_LIBRARY(G2O_TYPES_SLAM2D types_slam2d)
FIND_G2O_LIBRARY(G2O_TYPES_SLAM3D types_slam3d)# G2O solvers declared found if we found at least one solver
SET(G2O_SOLVERS_FOUND "NO")
IF(G2O_SOLVER_CHOLMOD OR G2O_SOLVER_CSPARSE OR G2O_SOLVER_DENSE OR G2O_SOLVER_PCG OR G2O_SOLVER_SLAM2D_LINEAR OR G2O_SOLVER_STRUCTURE_ONLY OR G2O_SOLVER_EIGEN)SET(G2O_SOLVERS_FOUND "YES")
ENDIF(G2O_SOLVER_CHOLMOD OR G2O_SOLVER_CSPARSE OR G2O_SOLVER_DENSE OR G2O_SOLVER_PCG OR G2O_SOLVER_SLAM2D_LINEAR OR G2O_SOLVER_STRUCTURE_ONLY OR G2O_SOLVER_EIGEN)# G2O itself declared found if we found the core libraries and at least one solver
SET(G2O_FOUND "NO")
IF(G2O_STUFF_LIBRARY AND G2O_CORE_LIBRARY AND G2O_INCLUDE_DIR AND G2O_SOLVERS_FOUND)SET(G2O_FOUND "YES")
ENDIF(G2O_STUFF_LIBRARY AND G2O_CORE_LIBRARY AND G2O_INCLUDE_DIR AND G2O_SOLVERS_FOUND)
修改为
FIND_PATH(G2O_INCLUDE_DIR g2o/core/base_vertex.h${G2O_ROOT}/include$ENV{G2O_ROOT}/include$ENV{G2O_ROOT}/usr/local/include/usr/include/opt/local/include/sw/local/include/sw/includeNO_DEFAULT_PATH)# Macro to unify finding both the debug and release versions of the
# libraries; this is adapted from the OpenSceneGraph FIND_LIBRARY
# macro.MACRO(FIND_G2O_LIBRARY MYLIBRARY MYLIBRARYNAME)FIND_LIBRARY("${MYLIBRARY}_DEBUG"NAMES "g2o_${MYLIBRARYNAME}_d"PATHS${G2O_ROOT}/lib/Debug${G2O_ROOT}/lib$ENV{G2O_ROOT}/lib/Debug$ENV{G2O_ROOT}/libNO_DEFAULT_PATH)FIND_LIBRARY("${MYLIBRARY}_DEBUG"NAMES "g2o_${MYLIBRARYNAME}_d"PATHS~/Library/Frameworks/Library/Frameworks/usr/local/lib/usr/local/lib64/usr/lib/usr/lib64/opt/local/lib/sw/local/lib/sw/libNO_DEFAULT_PATH)FIND_LIBRARY(${MYLIBRARY}NAMES "g2o_${MYLIBRARYNAME}"PATHS${G2O_ROOT}/lib/Release${G2O_ROOT}/lib$ENV{G2O_ROOT}/lib/Release$ENV{G2O_ROOT}/libNO_DEFAULT_PATH)FIND_LIBRARY(${MYLIBRARY}NAMES "g2o_${MYLIBRARYNAME}"PATHS~/Library/Frameworks/Library/Frameworks/usr/local/lib/usr/local/lib64/usr/lib/usr/lib64/opt/local/lib/sw/local/lib/sw/libNO_DEFAULT_PATH)IF(NOT ${MYLIBRARY}_DEBUG)IF(MYLIBRARY)SET(${MYLIBRARY}_DEBUG ${MYLIBRARY})ENDIF(MYLIBRARY)ENDIF( NOT ${MYLIBRARY}_DEBUG)ENDMACRO(FIND_G2O_LIBRARY LIBRARY LIBRARYNAME)# Find the core elements
FIND_G2O_LIBRARY(G2O_STUFF_LIBRARY stuff)
FIND_G2O_LIBRARY(G2O_CORE_LIBRARY core)# Find the CLI library
FIND_G2O_LIBRARY(G2O_CLI_LIBRARY cli)# Find the pluggable solvers
FIND_G2O_LIBRARY(G2O_SOLVER_CHOLMOD solver_cholmod)
FIND_G2O_LIBRARY(G2O_SOLVER_CSPARSE solver_csparse)
FIND_G2O_LIBRARY(G2O_SOLVER_CSPARSE_EXTENSION csparse_extension)
FIND_G2O_LIBRARY(G2O_SOLVER_DENSE solver_dense)
FIND_G2O_LIBRARY(G2O_SOLVER_PCG solver_pcg)
FIND_G2O_LIBRARY(G2O_SOLVER_SLAM2D_LINEAR solver_slam2d_linear)
FIND_G2O_LIBRARY(G2O_SOLVER_STRUCTURE_ONLY solver_structure_only)
FIND_G2O_LIBRARY(G2O_SOLVER_EIGEN solver_eigen)# Find the predefined types
FIND_G2O_LIBRARY(G2O_TYPES_DATA types_data)
FIND_G2O_LIBRARY(G2O_TYPES_ICP types_icp)
FIND_G2O_LIBRARY(G2O_TYPES_SBA types_sba)
FIND_G2O_LIBRARY(G2O_TYPES_SCLAM2D types_sclam2d)
FIND_G2O_LIBRARY(G2O_TYPES_SIM3 types_sim3)
FIND_G2O_LIBRARY(G2O_TYPES_SLAM2D types_slam2d)
FIND_G2O_LIBRARY(G2O_TYPES_SLAM3D types_slam3d)# G2O solvers declared found if we found at least one solver
SET(G2O_SOLVERS_FOUND "NO")
IF(G2O_SOLVER_CHOLMOD OR G2O_SOLVER_CSPARSE OR G2O_SOLVER_DENSE OR G2O_SOLVER_PCG OR G2O_SOLVER_SLAM2D_LINEAR OR G2O_SOLVER_STRUCTURE_ONLY OR G2O_SOLVER_EIGEN)SET(G2O_SOLVERS_FOUND "YES")
ENDIF(G2O_SOLVER_CHOLMOD OR G2O_SOLVER_CSPARSE OR G2O_SOLVER_DENSE OR G2O_SOLVER_PCG OR G2O_SOLVER_SLAM2D_LINEAR OR G2O_SOLVER_STRUCTURE_ONLY OR G2O_SOLVER_EIGEN)# G2O itself declared found if we found the core libraries and at least one solver
SET(G2O_FOUND "NO")
IF(G2O_STUFF_LIBRARY AND G2O_CORE_LIBRARY AND G2O_INCLUDE_DIR AND G2O_SOLVERS_FOUND)SET(G2O_FOUND "YES")
ENDIF(G2O_STUFF_LIBRARY AND G2O_CORE_LIBRARY AND G2O_INCLUDE_DIR AND G2O_SOLVERS_FOUND)
本质就是去掉默认目录,即FIND_LIBRARY只能在指定目录找库。
解决error: undefined reference to g2o::OptimizableGraph::addVertex问题相关推荐
- 解决Error: undefined reference to `__android_log_print'
解决Error: undefined reference to `__android_log_print' 最近在使用Android Studio进行NDK开发时,程序本身是没有问题,但一旦添 ...
- 【Qt】报错error: undefined reference to `vtable for的解决方法
1.问题描述 编译Qt程序时,在某个类构造函数定义处报错: error: undefined reference to `vtable for 2.原因分析 导致错误信息的原因是:子类没有实现父类的纯 ...
- Android系统编译so库提示error undefined reference to '__android_log_print问题的解决
在系统源代码的hardware/qcom下增加psam文件夹,编译源代码要生成libpsam.so库,Android.mk内容 LOCAL_PATH := $(call my-dir) include ...
- QT构建编译出现错误error: undefined reference to 的解决办法
这里要解决问题的是QT构建中的 error: undefined reference to 而不是 undefined reference to vtable for "xxx::xxx&q ...
- QT:error: undefined reference to 'xxxx'错误提示,解决方式
当你执行QT程序时,突然报错了这个错 error: undefined reference to 'xxxx' 表示未定义 函数 只需要把头文件里的 private slots的指定报错的函数去除了就 ...
- android error: undefined reference to 的错误分析
今天,简单讲讲android error: undefined reference to 的错误分析. 昨天,做jni,连接so库时,android studio出现了这个问题.当时不知道是什么 ...
- error: undefined reference to `_imp__glXXX@XX'
问题: 原文地址: https://blog.csdn.net/hebbely/article/details/69946155 如:error: undefined reference to `_i ...
- error: undefined reference to `PathTrace::PathTrace(World*)' (Codeblocks, C++)
error: undefined reference to `PathTrace::PathTrace(World*)' 说的是`PathTrace::PathTrace(World*)' 没有被& ...
- Qt 多线程bug:moc_widget.cpp:-1: error: undefined reference to `Mythread::~Mythread()‘:-1:
Qt 多线程 moc_widget.cpp:-1: error: undefined reference to `Mythread::~Mythread()' moc_widget.cpp:-1: e ...
最新文章
- 百度云加速 ajax,使用百度云加速后网站打开速度慢、广告不显示的解决方法
- 阿里达摩院包揽AI领域六大权威榜单冠军:用人类的学习方式超越人类
- teamviewer 可用设备上限_2020推荐香河气压罐专业供水设备
- 阿里云CDN技术 揭秘
- 华为emui10是鸿蒙,昨日,华为EMUI10,鸿蒙系统正式发布!
- nbu 恢复oracle数据库,关于使用nbu重定向恢复oracle数据库rman报错
- 360加固逆向脱壳之过反调试
- 【全网首发】京东商业数据分析师培养计划
- .NET 开源项目 StreamJsonRpc 介绍[下篇]
- vue项目cordova打包的android应用
- Centos 解压软件
- boobooke播布客
- 输出200以内所有素数(python)
- 牙齿,我怎么才能保护你
- Windows注册表知识
- 普渡机器人服务北京大学
- Population and carrying capacity 的第二阶段 :Crowding affects lifetime.
- 【数据安全案例】北京购车摇号查询系统出现信息泄露漏洞
- 无线路由器有几种工作模式
- 基于CNN的海面舰船图像二分类