当我在 /g2o-master/g2o/examples/ba/ba_demo.cpp 上测试 g2o 时,CMakeList.txt 如下所示:
FIND_PACKAGE( OpenCV 2.4 REQUIRED )
LIST( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules )
SET( G2O_ROOT /usr/local/include/g2o )
FIND_PACKAGE( G2O REQUIRED )
FIND_PACKAGE( CSparse REQUIRED )
INCLUDE_DIRECTORIES( ${G2O_INCLUDE_DIR} ${CSPARSE_INCLUDE_DIR} )
include_directories( "/usr/include/eigen3" )
SET( G2O_LIBS ${CSPARSE_LIBRARY} g2o_core g2o_stuff
g2o_solver_csparse g2o_types_slam3d
g2o_csparse_extension g2o_opengl_helper
g2o_solver_cholmod g2o_types_sba)
FIND_PACKAGE( Cholmod REQUIRED )
message(STATUS " Cholmod = " ${CHOLMOD_LIBRARY} )
message(STATUS " Cholmod = " ${CSPARSE_LIBRARY} )
ADD_EXECUTABLE(ba_demo ba_demo.cpp)
INCLUDE_DIRECTORIES(${CHOLMOD_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(ba_demo ${G2O_LIBS} ${CHOLMOD_LIBRARY} ***${OpenCV_LIBS}*** )
注意最后一行的 ${OpenCV_LIBS}。
运行 ba_demo,出现错误:“ * `../bin/ba_demo' 中的错误:malloc():内存损坏:0x00000000007b9320 * 中止(核心转储)”。
我的代码有什么问题吗?