Open Yu1993Yu opened 6 years ago
I have solved this just by homebrew install again g2o and the point is brew install g2o is much better than you cmake it by yourself, because the homebrew can auto cmake and link everything
and remember if you are working on macos, you must install the openmp by youself which is not mentioned in the book(because its working on Liunx)
Working on this for few days ....really need someone to help me out of it
I am working on Clion+Cmake in Mac OS 10.13 I copy all of code from slambook ch6 g2o_curve_fitting to my main.cpp, and I always got the error like this:
Undefined symbols for architecture x86_64: "_omp_destroy_lock", referenced from: g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::~BlockSolver() in main.cpp.o g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::resize(int, int, int, int, int) in main.cpp.o std::1::vector<g2o::OpenMPMutex, std::1::allocator >::__append(unsigned long) in main.cpp.o
"_omp_init_lock", referenced from:
std::1::vector<g2o::OpenMPMutex, std::1::allocator >::__append(unsigned long) in main.cpp.o
"_omp_set_lock", referenced from:
g2o::BaseUnaryEdge<1, double, CurveFittingVertex>::constructQuadraticForm() in main.cpp.o
g2o::BaseUnaryEdge<1, double, CurveFittingVertex>::linearizeOplus() in main.cpp.o
g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::solve() in main.cpp.o
"_omp_unset_lock", referenced from:
g2o::BaseUnaryEdge<1, double, CurveFittingVertex>::constructQuadraticForm() in main.cpp.o
g2o::BaseUnaryEdge<1, double, CurveFittingVertex>::linearizeOplus() in main.cpp.o
g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::solve() in main.cpp.o
ld: symbol(s) not found for architecture x86_64
PS:I have changed the g2o to which provided in 3rdparty
PS:I have installed the openmp in my computer, and I can locate _omp_destroy_lock "_omp_init_lock" "_omp_unset_lock" in the openmp_mutex.h
PS:It seems like the problem is about libraries but I have copy all of libs from g2o/lib to my local lib(of course I have cmake and make the g2o, and I copy the g2o files to the local/include )
PS:and my cmake like this:
`cmake_minimum_required(VERSION 3.8) project(g2o_cureve_fitting)
set( CMAKE_BUILD_TYPE "Release" ) set( CMAKE_CXX_FLAGS "-std=c++11 -O3" )
添加cmake模块以使用g2o库
list( APPEND CMAKE_MODULE_PATH /usr/local/Cellar/cmake/3.11.0/share/cmake/Modules )
set (OpenMP_CXX_FLAGS "-fopenmp")
寻找G2O
FIND_PACKAGE( G2O ) include_directories( ${G2O_INCLUDE_DIR} "/usr/local/Cellar/eigen/3.3.4/include/eigen3" )
OpenCV
find_package( OpenCV REQUIRED ) include_directories( ${OpenCV_DIRS} )
set(SOURCE_FILES main.cpp) add_executable(g2o_cureve_fitting ${SOURCE_FILES})
与G2O和OpenCV链接
target_link_libraries( g2o_cureve_fitting ${OpenCV_LIBS} ${G2O_CORE_LIBRARY} ${G2O_STUFF_LIBRARY} ) `
which I believed is not the point of my problem, just in case.
A lot of thanks to who can help me out