关于G2O库的坑~

 错误提示1:

/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o: in function `main':
g2o_demo.cpp:(.text+0x2d8): undefined reference to `g2o::OptimizationAlgorithmGaussNewton::OptimizationAlgorithmGaussNewton(std::unique_ptr<g2o::Solver, std::default_delete<g2o::Solver> >)'
/usr/bin/ld: g2o_demo.cpp:(.text+0x2fd): undefined reference to `g2o::SparseOptimizer::SparseOptimizer()'
/usr/bin/ld: g2o_demo.cpp:(.text+0x316): undefined reference to `g2o::SparseOptimizer::setAlgorithm(g2o::OptimizationAlgorithm*)'
/usr/bin/ld: g2o_demo.cpp:(.text+0x32a): undefined reference to `g2o::SparseOptimizer::setVerbose(bool)'
/usr/bin/ld: g2o_demo.cpp:(.text+0x440): undefined reference to `g2o::HyperGraph::Edge::setId(int)'
/usr/bin/ld: g2o_demo.cpp:(.text+0x54b): undefined reference to `g2o::OptimizableGraph::addEdge(g2o::OptimizableGraph::Edge*)'
/usr/bin/ld: g2o_demo.cpp:(.text+0x593): undefined reference to `g2o::SparseOptimizer::initializeOptimization(int)'
/usr/bin/ld: g2o_demo.cpp:(.text+0x5ac): undefined reference to `g2o::SparseOptimizer::optimize(int, bool)'
/usr/bin/ld: g2o_demo.cpp:(.text+0x631): undefined reference to `g2o::SparseOptimizer::~SparseOptimizer()'
/usr/bin/ld: g2o_demo.cpp:(.text+0x751): undefined reference to `g2o::SparseOptimizer::~SparseOptimizer()'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o: in function `g2o::OptimizableGraph::addVertex(g2o::OptimizableGraph::Vertex*)':
g2o_demo.cpp:(.text._ZN3g2o16OptimizableGraph9addVertexEPNS0_6VertexE[_ZN3g2o16OptimizableGraph9addVertexEPNS0_6VertexE]+0x28): undefined reference to `g2o::OptimizableGraph::addVertex(g2o::OptimizableGraph::Vertex*, g2o::HyperGraph::Data*)'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o: in function `g2o::BlockSolverBase::~BlockSolverBase()':
g2o_demo.cpp:(.text._ZN3g2o15BlockSolverBaseD2Ev[_ZN3g2o15BlockSolverBaseD5Ev]+0x26): undefined reference to `g2o::Solver::~Solver()'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o: in function `g2o::G2OBatchStatistics::globalStats()':
g2o_demo.cpp:(.text._ZN3g2o18G2OBatchStatistics11globalStatsEv[_ZN3g2o18G2OBatchStatistics11globalStatsEv]+0xb): undefined reference to `g2o::G2OBatchStatistics::_globalStats'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o: in function `g2o::BaseVertex<3, Eigen::Matrix<double, 3, 1, 0, 3, 1> >::~BaseVertex()':
g2o_demo.cpp:(.text._ZN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEED2Ev[_ZN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEED5Ev]+0x47): undefined reference to `g2o::OptimizableGraph::Vertex::~Vertex()'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o: in function `g2o::BaseEdge<1, double>::~BaseEdge()':
g2o_demo.cpp:(.text._ZN3g2o8BaseEdgeILi1EdED2Ev[_ZN3g2o8BaseEdgeILi1EdED5Ev]+0x35): undefined reference to `g2o::OptimizableGraph::Edge::~Edge()'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o: in function `g2o::BlockSolverBase::BlockSolverBase()':
g2o_demo.cpp:(.text._ZN3g2o15BlockSolverBaseC2Ev[_ZN3g2o15BlockSolverBaseC5Ev]+0x18): undefined reference to `g2o::Solver::Solver()'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o: in function `g2o::BaseVertex<3, Eigen::Matrix<double, 3, 1, 0, 3, 1> >::BaseVertex()':
g2o_demo.cpp:(.text._ZN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEC2Ev[_ZN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEC5Ev]+0x28): undefined reference to `g2o::OptimizableGraph::Vertex::Vertex()'
/usr/bin/ld: g2o_demo.cpp:(.text._ZN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEC2Ev[_ZN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEC5Ev]+0xe0): undefined reference to `g2o::OptimizableGraph::Vertex::~Vertex()'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o: in function `g2o::BaseEdge<1, double>::BaseEdge()':
g2o_demo.cpp:(.text._ZN3g2o8BaseEdgeILi1EdEC2Ev[_ZN3g2o8BaseEdgeILi1EdEC5Ev]+0x19): undefined reference to `g2o::OptimizableGraph::Edge::Edge()'
/usr/bin/ld: g2o_demo.cpp:(.text._ZN3g2o8BaseEdgeILi1EdEC2Ev[_ZN3g2o8BaseEdgeILi1EdEC5Ev]+0x7a): undefined reference to `g2o::OptimizableGraph::Edge::~Edge()'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTV16CuverFittingEdge[_ZTV16CuverFittingEdge]+0x40): undefined reference to `g2o::OptimizableGraph::Edge::setMeasurementData(double const*)'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTV16CuverFittingEdge[_ZTV16CuverFittingEdge]+0x48): undefined reference to `g2o::OptimizableGraph::Edge::getMeasurementData(double*) const'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTV16CuverFittingEdge[_ZTV16CuverFittingEdge]+0x50): undefined reference to `g2o::OptimizableGraph::Edge::measurementDimension() const'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTV16CuverFittingEdge[_ZTV16CuverFittingEdge]+0x58): undefined reference to `g2o::OptimizableGraph::Edge::setMeasurementFromState()'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTV16CuverFittingEdge[_ZTV16CuverFittingEdge]+0xd8): undefined reference to `g2o::OptimizableGraph::Edge::resolveCaches()'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o13BaseUnaryEdgeILi1Ed18CurveFittingVertexEE[_ZTVN3g2o13BaseUnaryEdgeILi1Ed18CurveFittingVertexEE]+0x40): undefined reference to `g2o::OptimizableGraph::Edge::setMeasurementData(double const*)'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o13BaseUnaryEdgeILi1Ed18CurveFittingVertexEE[_ZTVN3g2o13BaseUnaryEdgeILi1Ed18CurveFittingVertexEE]+0x48): undefined reference to `g2o::OptimizableGraph::Edge::getMeasurementData(double*) const'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o13BaseUnaryEdgeILi1Ed18CurveFittingVertexEE[_ZTVN3g2o13BaseUnaryEdgeILi1Ed18CurveFittingVertexEE]+0x50): undefined reference to `g2o::OptimizableGraph::Edge::measurementDimension() const'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o13BaseUnaryEdgeILi1Ed18CurveFittingVertexEE[_ZTVN3g2o13BaseUnaryEdgeILi1Ed18CurveFittingVertexEE]+0x58): undefined reference to `g2o::OptimizableGraph::Edge::setMeasurementFromState()'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o13BaseUnaryEdgeILi1Ed18CurveFittingVertexEE[_ZTVN3g2o13BaseUnaryEdgeILi1Ed18CurveFittingVertexEE]+0xd8): undefined reference to `g2o::OptimizableGraph::Edge::resolveCaches()'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEEE[_ZTVN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEEE]+0x40): undefined reference to `g2o::OptimizableGraph::Edge::setMeasurementData(double const*)'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEEE[_ZTVN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEEE]+0x48): undefined reference to `g2o::OptimizableGraph::Edge::getMeasurementData(double*) const'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEEE[_ZTVN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEEE]+0x50): undefined reference to `g2o::OptimizableGraph::Edge::measurementDimension() const'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEEE[_ZTVN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEEE]+0x58): undefined reference to `g2o::OptimizableGraph::Edge::setMeasurementFromState()'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEEE[_ZTVN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEEE]+0xd8): undefined reference to `g2o::OptimizableGraph::Edge::resolveCaches()'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o8BaseEdgeILi1EdEE[_ZTVN3g2o8BaseEdgeILi1EdEE]+0x28): undefined reference to `g2o::HyperGraph::Edge::resize(unsigned long)'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o8BaseEdgeILi1EdEE[_ZTVN3g2o8BaseEdgeILi1EdEE]+0x40): undefined reference to `g2o::OptimizableGraph::Edge::setMeasurementData(double const*)'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o8BaseEdgeILi1EdEE[_ZTVN3g2o8BaseEdgeILi1EdEE]+0x48): undefined reference to `g2o::OptimizableGraph::Edge::getMeasurementData(double*) const'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o8BaseEdgeILi1EdEE[_ZTVN3g2o8BaseEdgeILi1EdEE]+0x50): undefined reference to `g2o::OptimizableGraph::Edge::measurementDimension() const'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o8BaseEdgeILi1EdEE[_ZTVN3g2o8BaseEdgeILi1EdEE]+0x58): undefined reference to `g2o::OptimizableGraph::Edge::setMeasurementFromState()'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o8BaseEdgeILi1EdEE[_ZTVN3g2o8BaseEdgeILi1EdEE]+0xd8): undefined reference to `g2o::OptimizableGraph::Edge::resolveCaches()'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTV18CurveFittingVertex[_ZTV18CurveFittingVertex]+0x88): undefined reference to `g2o::OptimizableGraph::Vertex::getEstimateData(double*) const'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTV18CurveFittingVertex[_ZTV18CurveFittingVertex]+0x98): undefined reference to `g2o::OptimizableGraph::Vertex::estimateDimension() const'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTV18CurveFittingVertex[_ZTV18CurveFittingVertex]+0xa0): undefined reference to `g2o::OptimizableGraph::Vertex::getMinimalEstimateData(double*) const'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTV18CurveFittingVertex[_ZTV18CurveFittingVertex]+0xb0): undefined reference to `g2o::OptimizableGraph::Vertex::minimalEstimateDimension() const'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTV18CurveFittingVertex[_ZTV18CurveFittingVertex]+0xe8): undefined reference to `g2o::OptimizableGraph::Vertex::updateCache()'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE[_ZTVN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE]+0x88): undefined reference to `g2o::OptimizableGraph::Vertex::getEstimateData(double*) const'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE[_ZTVN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE]+0x98): undefined reference to `g2o::OptimizableGraph::Vertex::estimateDimension() const'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE[_ZTVN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE]+0xa0): undefined reference to `g2o::OptimizableGraph::Vertex::getMinimalEstimateData(double*) const'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE[_ZTVN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE]+0xb0): undefined reference to `g2o::OptimizableGraph::Vertex::minimalEstimateDimension() const'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTVN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE[_ZTVN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE]+0xe8): undefined reference to `g2o::OptimizableGraph::Vertex::updateCache()'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTIN3g2o8BaseEdgeILi1EdEE[_ZTIN3g2o8BaseEdgeILi1EdEE]+0x10): undefined reference to `typeinfo for g2o::OptimizableGraph::Edge'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTIN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE[_ZTIN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE]+0x10): undefined reference to `typeinfo for g2o::OptimizableGraph::Vertex'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:(.data.rel.ro._ZTIN3g2o15BlockSolverBaseE[_ZTIN3g2o15BlockSolverBaseE]+0x10): undefined reference to `typeinfo for g2o::Solver'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o: in function `g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::updateStructure(std::vector<g2o::HyperGraph::Vertex*, std::allocator<g2o::HyperGraph::Vertex*> > const&, std::set<g2o::HyperGraph::Edge*, std::less<g2o::HyperGraph::Edge*>, std::allocator<g2o::HyperGraph::Edge*> > const&)':
g2o_demo.cpp:(.text._ZN3g2o11BlockSolverINS_17BlockSolverTraitsILi3ELi1EEEE15updateStructureERKSt6vectorIPNS_10HyperGraph6VertexESaIS7_EERKSt3setIPNS5_4EdgeESt4lessISE_ESaISE_EE[_ZN3g2o11BlockSolverINS_17BlockSolverTraitsILi3ELi1EEEE15updateStructureERKSt6vectorIPNS_10HyperGraph6VertexESaIS7_EERKSt3setIPNS5_4EdgeESt4lessISE_ESaISE_EE]+0x2cd): undefined reference to `g2o::Solver::resizeVector(unsigned long)'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o: in function `g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::solve()':
g2o_demo.cpp:(.text._ZN3g2o11BlockSolverINS_17BlockSolverTraitsILi3ELi1EEEE5solveEv[_ZN3g2o11BlockSolverINS_17BlockSolverTraitsILi3ELi1EEEE5solveEv]+0x46): undefined reference to `g2o::get_monotonic_time()'
/usr/bin/ld: g2o_demo.cpp:(.text._ZN3g2o11BlockSolverINS_17BlockSolverTraitsILi3ELi1EEEE5solveEv[_ZN3g2o11BlockSolverINS_17BlockSolverTraitsILi3ELi1EEEE5solveEv]+0xcb): undefined reference to `g2o::get_monotonic_time()'
/usr/bin/ld: g2o_demo.cpp:(.text._ZN3g2o11BlockSolverINS_17BlockSolverTraitsILi3ELi1EEEE5solveEv[_ZN3g2o11BlockSolverINS_17BlockSolverTraitsILi3ELi1EEEE5solveEv]+0x138): undefined reference to `g2o::get_monotonic_time()'
/usr/bin/ld: g2o_demo.cpp:(.text._ZN3g2o11BlockSolverINS_17BlockSolverTraitsILi3ELi1EEEE5solveEv[_ZN3g2o11BlockSolverINS_17BlockSolverTraitsILi3ELi1EEEE5solveEv]+0xaca): undefined reference to `g2o::get_monotonic_time()'
/usr/bin/ld: g2o_demo.cpp:(.text._ZN3g2o11BlockSolverINS_17BlockSolverTraitsILi3ELi1EEEE5solveEv[_ZN3g2o11BlockSolverINS_17BlockSolverTraitsILi3ELi1EEEE5solveEv]+0xae3): undefined reference to `g2o::get_monotonic_time()'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o:g2o_demo.cpp:(.text._ZN3g2o11BlockSolverINS_17BlockSolverTraitsILi3ELi1EEEE5solveEv[_ZN3g2o11BlockSolverINS_17BlockSolverTraitsILi3ELi1EEEE5solveEv]+0xb6d): more undefined references to `g2o::get_monotonic_time()' follow
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o: in function `g2o::BaseFixedSizedEdge<1, double, CurveFittingVertex>::resize(unsigned long)':
g2o_demo.cpp:(.text._ZN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEE6resizeEm[_ZN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEE6resizeEm]+0x49): undefined reference to `g2o::HyperGraph::Edge::resize(unsigned long)'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o: in function `g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::resize(int*, int, int*, int, int)':
g2o_demo.cpp:(.text._ZN3g2o11BlockSolverINS_17BlockSolverTraitsILi3ELi1EEEE6resizeEPiiS4_ii[_ZN3g2o11BlockSolverINS_17BlockSolverTraitsILi3ELi1EEEE6resizeEPiiS4_ii]+0x50): undefined reference to `g2o::Solver::resizeVector(unsigned long)'
collect2: error: ld returned 1 exit status
make[2]: *** [g2o_pkg/CMakeFiles/g2o_demo.dir/build.make:168:/home/frank/g2o_demo/devel/lib/g2o_pkg/g2o_demo] 错误 1
make[1]: *** [CMakeFiles/Makefile2:418:g2o_pkg/CMakeFiles/g2o_demo.dir/all] 错误 2
make: *** [Makefile:141:all] 错误 2

解决:再CMakeList.txt中加入

target_link_libraries(g2o_demo  ${catkin_LIBRARIES} g2o_core g2o_types_slam3d g2o_solver_csparse g2o_stuff g2o_csparse_extension)

错误提示2:

usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o: in function `ceres::internal::FixedArray<double, 3ul, std::allocator<double> >::operator[](unsigned long)':
g2o_demo.cpp:(.text._ZN5ceres8internal10FixedArrayIdLm3ESaIdEEixEm[_ZN5ceres8internal10FixedArrayIdLm3ESaIdEEixEm]+0x9e): undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int, google::CheckOpString const&)'
/usr/bin/ld: g2o_demo.cpp:(.text._ZN5ceres8internal10FixedArrayIdLm3ESaIdEEixEm[_ZN5ceres8internal10FixedArrayIdLm3ESaIdEEixEm]+0xaa): undefined reference to `google::LogMessage::stream()'
/usr/bin/ld: g2o_demo.cpp:(.text._ZN5ceres8internal10FixedArrayIdLm3ESaIdEEixEm[_ZN5ceres8internal10FixedArrayIdLm3ESaIdEEixEm]+0xb6): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
/usr/bin/ld: g2o_demo.cpp:(.text._ZN5ceres8internal10FixedArrayIdLm3ESaIdEEixEm[_ZN5ceres8internal10FixedArrayIdLm3ESaIdEEixEm]+0xee): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
/usr/bin/ld: CMakeFiles/g2o_demo.dir/src/g2o_demo.cpp.o: in function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >* google::MakeCheckOpString<unsigned long, unsigned long>(unsigned long const&, unsigned long const&, char const*)':
g2o_demo.cpp:(.text._ZN6google17MakeCheckOpStringImmEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc[_ZN6google17MakeCheckOpStringImmEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc]+0x37): undefined reference to `google::base::CheckOpMessageBuilder::CheckOpMessageBuilder(char const*)'
/usr/bin/ld: g2o_demo.cpp:(.text._ZN6google17MakeCheckOpStringImmEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc[_ZN6google17MakeCheckOpStringImmEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc]+0x61): undefined reference to `google::base::CheckOpMessageBuilder::ForVar2()'
/usr/bin/ld: g2o_demo.cpp:(.text._ZN6google17MakeCheckOpStringImmEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc[_ZN6google17MakeCheckOpStringImmEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc]+0x7f): undefined reference to `google::base::CheckOpMessageBuilder::NewString[abi:cxx11]()'
/usr/bin/ld: g2o_demo.cpp:(.text._ZN6google17MakeCheckOpStringImmEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc[_ZN6google17MakeCheckOpStringImmEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc]+0x8f): undefined reference to `google::base::CheckOpMessageBuilder::~CheckOpMessageBuilder()'
/usr/bin/ld: g2o_demo.cpp:(.text._ZN6google17MakeCheckOpStringImmEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc[_ZN6google17MakeCheckOpStringImmEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc]+0xb6): undefined reference to `google::base::CheckOpMessageBuilder::~CheckOpMessageBuilder()'
collect2: error: ld returned 1 exit status
make[2]: *** [g2o_pkg/CMakeFiles/g2o_demo.dir/build.make:166:/home/frank/g2o_demo/devel/lib/g2o_pkg/g2o_demo] 错误 1
make[1]: *** [CMakeFiles/Makefile2:418:g2o_pkg/CMakeFiles/g2o_demo.dir/all] 错误 2
make: *** [Makefile:141:all] 错误 2

解决:要在库里链接ceres库。

错误提示3:这个错误实在运行程序不是在编译的时候出现的

error while loading shared libraries: libg2o_core.so: cannot open shared object file: No such file or directory

解决办法:error while loading shared libraries: libg2o_core.so: cannot open shared object file: No such file o - hanny-liu - 博客园 (cnblogs.com)

  • 5
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值