ad_520 2023-01-17 12:07 采纳率: 100%
浏览 76
已结题

视觉SLAM十四讲ch6

视觉SLAM十四讲ch6程序g2oCurveFitting编译问题
我的系统是Ubuntu22.04,g2o库是最新版

CMakeLists如下:

cmake_minimum_required(VERSION 2.8)
project(ch6)

set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS "-std=c++14 -O3")

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

# OpenCV
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})

# Ceres
find_package(Ceres REQUIRED)
include_directories(${CERES_INCLUDE_DIRS})

# g2o
find_package(G2O REQUIRED)
include_directories(${G2O_INCLUDE_DIRS})

# Eigen
include_directories("/usr/include/eigen3")

add_executable(gaussNewton gaussNewton.cpp)
target_link_libraries(gaussNewton ${OpenCV_LIBS})

add_executable(ceresCurveFitting ceresCurveFitting.cpp)
target_link_libraries(ceresCurveFitting ${OpenCV_LIBS} ${CERES_LIBRARIES})

add_executable(g2oCurveFitting g2oCurveFitting.cpp)
target_link_libraries(g2oCurveFitting ${OpenCV_LIBS} ${G2O_CORE_LIBRARIES} ${G2O_SOLVERS_LIBRARIES})

g2oCurveFitting.cpp如下:

#include <iostream>
#include <g2o/core/g2o_core_api.h>
#include <g2o/core/base_vertex.h>
#include <g2o/core/base_unary_edge.h>
#include <g2o/core/block_solver.h>
#include <g2o/core/optimization_algorithm_levenberg.h>
#include <g2o/core/optimization_algorithm_gauss_newton.h>
#include <g2o/core/optimization_algorithm_dogleg.h>
#include <g2o/solvers/dense/linear_solver_dense.h>
#include <Eigen/Core>
#include <opencv2/core/core.hpp>
#include <cmath>
#include <chrono>

using namespace std;

// 曲线模型的顶点,模板参数:优化变量维度和数据类型
class CurveFittingVertex : public g2o::BaseVertex<3, Eigen::Vector3d> {
public:
  EIGEN_MAKE_ALIGNED_OPERATOR_NEW

  // 重置
  virtual void setToOriginImpl() override {
    _estimate << 0, 0, 0;
  }

  // 更新
  virtual void oplusImpl(const double *update) override {
    _estimate += Eigen::Vector3d(update);
  }

  // 存盘和读盘:留空
  virtual bool read(istream &in) {}

  virtual bool write(ostream &out) const {}
};

// 误差模型 模板参数:观测值维度,类型,连接顶点类型
class CurveFittingEdge : public g2o::BaseUnaryEdge<1, double, CurveFittingVertex> {
public:
  EIGEN_MAKE_ALIGNED_OPERATOR_NEW

  CurveFittingEdge(double x) : BaseUnaryEdge(), _x(x) {}

  // 计算曲线模型误差
  virtual void computeError() override {
    const CurveFittingVertex *v = static_cast<const CurveFittingVertex *> (_vertices[0]);
    const Eigen::Vector3d abc = v->estimate();
    _error(0, 0) = _measurement - std::exp(abc(0, 0) * _x * _x + abc(1, 0) * _x + abc(2, 0));
  }

  // 计算雅可比矩阵
  virtual void linearizeOplus() override {
    const CurveFittingVertex *v = static_cast<const CurveFittingVertex *> (_vertices[0]);
    const Eigen::Vector3d abc = v->estimate();
    double y = exp(abc[0] * _x * _x + abc[1] * _x + abc[2]);
    _jacobianOplusXi[0] = -_x * _x * y;
    _jacobianOplusXi[1] = -_x * y;
    _jacobianOplusXi[2] = -y;
  }

  virtual bool read(istream &in) {}

  virtual bool write(ostream &out) const {}

public:
  double _x;  // x 值, y 值为 _measurement
};

int main(int argc, char **argv) {
  double ar = 1.0, br = 2.0, cr = 1.0;         // 真实参数值
  double ae = 2.0, be = -1.0, ce = 5.0;        // 估计参数值
  int N = 100;                                 // 数据点
  double w_sigma = 1.0;                        // 噪声Sigma值
  double inv_sigma = 1.0 / w_sigma;
  cv::RNG rng;                                 // OpenCV随机数产生器

  vector<double> x_data, y_data;      // 数据
  for (int i = 0; i < N; i++) {
    double x = i / 100.0;
    x_data.push_back(x);
    y_data.push_back(exp(ar * x * x + br * x + cr) + rng.gaussian(w_sigma * w_sigma));
  }

  // 构建图优化,先设定g2o
  typedef g2o::BlockSolver<g2o::BlockSolverTraits<3, 1>> BlockSolverType;  // 每个误差项优化变量维度为3,误差值维度为1
  typedef g2o::LinearSolverDense<BlockSolverType::PoseMatrixType> LinearSolverType; // 线性求解器类型

  // 梯度下降方法,可以从GN, LM, DogLeg 中选
  auto solver = new g2o::OptimizationAlgorithmGaussNewton(
    g2o::make_unique<BlockSolverType>(g2o::make_unique<LinearSolverType>()));
  g2o::SparseOptimizer optimizer;     // 图模型
  optimizer.setAlgorithm(solver);   // 设置求解器
  optimizer.setVerbose(true);       // 打开调试输出

  // 往图中增加顶点
  CurveFittingVertex *v = new CurveFittingVertex();
  v->setEstimate(Eigen::Vector3d(ae, be, ce));
  v->setId(0);
  optimizer.addVertex(v);

  // 往图中增加边
  for (int i = 0; i < N; i++) {
    CurveFittingEdge *edge = new CurveFittingEdge(x_data[i]);
    edge->setId(i);
    edge->setVertex(0, v);                // 设置连接的顶点
    edge->setMeasurement(y_data[i]);      // 观测数值
    edge->setInformation(Eigen::Matrix<double, 1, 1>::Identity() * 1 / (w_sigma * w_sigma)); // 信息矩阵:协方差矩阵之逆
    optimizer.addEdge(edge);
  }

  // 执行优化
  cout << "start optimization" << endl;
  chrono::steady_clock::time_point t1 = chrono::steady_clock::now();
  optimizer.initializeOptimization();
  optimizer.optimize(10);
  chrono::steady_clock::time_point t2 = chrono::steady_clock::now();
  chrono::duration<double> time_used = chrono::duration_cast<chrono::duration<double>>(t2 - t1);
  cout << "solve time cost = " << time_used.count() << " seconds. " << endl;

  // 输出优化值
  Eigen::Vector3d abc_estimate = v->estimate();
  cout << "estimated model: " << abc_estimate.transpose() << endl;

  return 0;
}

make编译出错:

/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: warning: relocation against `_ZN3g2o18G2OBatchStatistics12_globalStatsE' in read-only section `.text._ZN3g2o11BlockSolverINS_17BlockSolverTraitsILi3ELi1EEEE5solveEv[_ZN3g2o11BlockSolverINS_17BlockSolverTraitsILi3ELi1EEEE5solveEv]'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::BaseEdge<1, double>::~BaseEdge()':
/usr/local/include/g2o/core/base_edge.h:96: undefined reference to `g2o::OptimizableGraph::Edge::~Edge()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `non-virtual thunk to CurveFittingEdge::~CurveFittingEdge()':
/usr/local/include/g2o/core/base_edge.h:96: undefined reference to `g2o::OptimizableGraph::Edge::~Edge()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::BaseEdge<1, double>::~BaseEdge()':
/usr/local/include/g2o/core/base_edge.h:96: undefined reference to `g2o::OptimizableGraph::Edge::~Edge()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `non-virtual thunk to CurveFittingEdge::~CurveFittingEdge()':
/usr/include/eigen3/Eigen/src/Core/util/Memory.h:203: undefined reference to `g2o::OptimizableGraph::Edge::~Edge()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::BaseFixedSizedEdge<1, double, CurveFittingVertex>::resize(unsigned long)':
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:31: undefined reference to `g2o::HyperGraph::Edge::resize(unsigned long)'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::computeMarginals(g2o::SparseBlockMatrix<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > const&)':
/usr/local/include/g2o/core/block_solver.hpp:485: undefined reference to `g2o::get_monotonic_time()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::G2OBatchStatistics::globalStats()':
/usr/local/include/g2o/core/batch_stats.h:79: undefined reference to `g2o::G2OBatchStatistics::_globalStats'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::computeMarginals(g2o::SparseBlockMatrix<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > const&)':
/usr/local/include/g2o/core/block_solver.hpp:489: undefined reference to `g2o::get_monotonic_time()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::BaseVertex<3, Eigen::Matrix<double, 3, 1, 0, 3, 1> >::~BaseVertex()':
/usr/local/include/g2o/core/base_vertex.h:50: undefined reference to `g2o::OptimizableGraph::Vertex::~Vertex()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `non-virtual thunk to CurveFittingVertex::~CurveFittingVertex()':
/usr/local/include/g2o/core/base_vertex.h:50: undefined reference to `g2o::OptimizableGraph::Vertex::~Vertex()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::BaseVertex<3, Eigen::Matrix<double, 3, 1, 0, 3, 1> >::~BaseVertex()':
/usr/local/include/g2o/core/base_vertex.h:50: undefined reference to `g2o::OptimizableGraph::Vertex::~Vertex()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `non-virtual thunk to CurveFittingVertex::~CurveFittingVertex()':
/usr/include/eigen3/Eigen/src/Core/util/Memory.h:203: undefined reference to `g2o::OptimizableGraph::Vertex::~Vertex()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::BlockSolverBase::BlockSolverBase()':
/usr/local/include/g2o/core/block_solver.h:90: undefined reference to `g2o::Solver::Solver()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::BlockSolverBase::~BlockSolverBase()':
/usr/local/include/g2o/core/block_solver.h:92: undefined reference to `g2o::Solver::~Solver()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::resize(int*, int, int*, int, int)':
/usr/local/include/g2o/core/block_solver.hpp:56: undefined reference to `g2o::Solver::resizeVector(unsigned long)'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::BaseEdge<1, double>::~BaseEdge()':
/usr/local/include/g2o/core/base_edge.h:96: undefined reference to `g2o::OptimizableGraph::Edge::~Edge()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `main.cold':
/home/zsh/VSLAM/Programs/Notmycode/slambook2/ch6/g2oCurveFitting.cpp:126: undefined reference to `g2o::SparseOptimizer::~SparseOptimizer()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::solve()':
/usr/local/include/g2o/core/block_solver.hpp:346: undefined reference to `g2o::get_monotonic_time()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::G2OBatchStatistics::globalStats()':
/usr/local/include/g2o/core/batch_stats.h:79: undefined reference to `g2o::G2OBatchStatistics::_globalStats'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::solve()':
/usr/local/include/g2o/core/block_solver.hpp:436: undefined reference to `g2o::get_monotonic_time()'
/usr/bin/ld: /usr/local/include/g2o/core/block_solver.hpp:439: undefined reference to `g2o::get_monotonic_time()'
/usr/bin/ld: /usr/local/include/g2o/core/block_solver.hpp:442: undefined reference to `g2o::get_monotonic_time()'
/usr/bin/ld: /usr/local/include/g2o/core/block_solver.hpp:332: undefined reference to `g2o::get_monotonic_time()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::G2OBatchStatistics::globalStats()':
/usr/local/include/g2o/core/batch_stats.h:79: undefined reference to `g2o::G2OBatchStatistics::_globalStats'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::solve()':
/usr/local/include/g2o/core/block_solver.hpp:336: undefined reference to `g2o::get_monotonic_time()'
/usr/bin/ld: /usr/local/include/g2o/core/block_solver.hpp:439: undefined reference to `g2o::get_monotonic_time()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.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&)':
/usr/local/include/g2o/core/block_solver.hpp:292: undefined reference to `g2o::Solver::resizeVector(unsigned long)'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.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*)':
/usr/include/glog/logging.h:694: undefined reference to `google::base::CheckOpMessageBuilder::CheckOpMessageBuilder(char const*)'
/usr/bin/ld: /usr/include/glog/logging.h:696: undefined reference to `google::base::CheckOpMessageBuilder::ForVar2()'
/usr/bin/ld: /usr/include/glog/logging.h:697: undefined reference to `google::base::CheckOpMessageBuilder::NewString[abi:cxx11]()'
/usr/bin/ld: /usr/include/glog/logging.h:698: undefined reference to `google::base::CheckOpMessageBuilder::~CheckOpMessageBuilder()'
/usr/bin/ld: /usr/include/glog/logging.h:698: undefined reference to `google::base::CheckOpMessageBuilder::~CheckOpMessageBuilder()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `ceres::internal::FixedArray<double, 3ul, std::allocator<double> >::operator[](unsigned long)':
/usr/local/include/ceres/internal/fixed_array.h:215: undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int, google::CheckOpString const&)'
/usr/bin/ld: /usr/local/include/ceres/internal/fixed_array.h:215: undefined reference to `google::LogMessage::stream()'
/usr/bin/ld: /usr/local/include/ceres/internal/fixed_array.h:215: undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int, google::CheckOpString const&)'
/usr/bin/ld: /usr/local/include/ceres/internal/fixed_array.h:215: undefined reference to `google::LogMessage::stream()'
/usr/bin/ld: /usr/local/include/ceres/internal/fixed_array.h:215: undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int, google::CheckOpString const&)'
/usr/bin/ld: /usr/local/include/ceres/internal/fixed_array.h:215: undefined reference to `google::LogMessage::stream()'
/usr/bin/ld: /usr/local/include/ceres/internal/fixed_array.h:215: undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `main':
/home/zsh/VSLAM/Programs/Notmycode/slambook2/ch6/g2oCurveFitting.cpp:91: undefined reference to `g2o::OptimizationAlgorithmGaussNewton::OptimizationAlgorithmGaussNewton(std::unique_ptr<g2o::Solver, std::default_delete<g2o::Solver> >)'
/usr/bin/ld: /home/zsh/VSLAM/Programs/Notmycode/slambook2/ch6/g2oCurveFitting.cpp:92: undefined reference to `g2o::SparseOptimizer::SparseOptimizer()'
/usr/bin/ld: /home/zsh/VSLAM/Programs/Notmycode/slambook2/ch6/g2oCurveFitting.cpp:93: undefined reference to `g2o::SparseOptimizer::setAlgorithm(g2o::OptimizationAlgorithm*)'
/usr/bin/ld: /home/zsh/VSLAM/Programs/Notmycode/slambook2/ch6/g2oCurveFitting.cpp:94: undefined reference to `g2o::SparseOptimizer::setVerbose(bool)'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::BaseVertex<3, Eigen::Matrix<double, 3, 1, 0, 3, 1> >::BaseVertex()':
/usr/local/include/g2o/core/base_vertex.hpp:29: undefined reference to `g2o::OptimizableGraph::Vertex::Vertex()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::BaseVertex<3, Eigen::Matrix<double, 3, 1, 0, 3, 1> >::setEstimate(Eigen::Matrix<double, 3, 1, 0, 3, 1> const&)':
/usr/local/include/g2o/core/base_vertex.h:133: undefined reference to `g2o::OptimizableGraph::Vertex::updateCache()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::OptimizableGraph::addVertex(g2o::OptimizableGraph::Vertex*)':
/usr/local/include/g2o/core/optimizable_graph.h:597: undefined reference to `g2o::OptimizableGraph::addVertex(g2o::OptimizableGraph::Vertex*, g2o::HyperGraph::Data*)'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `g2o::BaseEdge<1, double>::BaseEdge()':
/usr/local/include/g2o/core/base_edge.h:94: undefined reference to `g2o::OptimizableGraph::Edge::Edge()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o: in function `main':
/home/zsh/VSLAM/Programs/Notmycode/slambook2/ch6/g2oCurveFitting.cpp:105: undefined reference to `g2o::HyperGraph::Edge::setId(int)'
/usr/bin/ld: /home/zsh/VSLAM/Programs/Notmycode/slambook2/ch6/g2oCurveFitting.cpp:109: undefined reference to `g2o::OptimizableGraph::addEdge(g2o::OptimizableGraph::Edge*)'
/usr/bin/ld: /home/zsh/VSLAM/Programs/Notmycode/slambook2/ch6/g2oCurveFitting.cpp:115: undefined reference to `g2o::SparseOptimizer::initializeOptimization(int)'
/usr/bin/ld: /home/zsh/VSLAM/Programs/Notmycode/slambook2/ch6/g2oCurveFitting.cpp:116: undefined reference to `g2o::SparseOptimizer::optimize(int, bool)'
/usr/bin/ld: /home/zsh/VSLAM/Programs/Notmycode/slambook2/ch6/g2oCurveFitting.cpp:126: undefined reference to `g2o::SparseOptimizer::~SparseOptimizer()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTIN3g2o15BlockSolverBaseE[_ZTIN3g2o15BlockSolverBaseE]+0x10): undefined reference to `typeinfo for g2o::Solver'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTIN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE[_ZTIN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE]+0x10): undefined reference to `typeinfo for g2o::OptimizableGraph::Vertex'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTIN3g2o8BaseEdgeILi1EdEE[_ZTIN3g2o8BaseEdgeILi1EdEE]+0x10): undefined reference to `typeinfo for g2o::OptimizableGraph::Edge'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTVN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE[_ZTVN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE]+0x88): undefined reference to `g2o::OptimizableGraph::Vertex::getEstimateData(double*) const'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTVN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE[_ZTVN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE]+0x98): undefined reference to `g2o::OptimizableGraph::Vertex::estimateDimension() const'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTVN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE[_ZTVN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE]+0xa0): undefined reference to `g2o::OptimizableGraph::Vertex::getMinimalEstimateData(double*) const'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTVN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE[_ZTVN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE]+0xb0): undefined reference to `g2o::OptimizableGraph::Vertex::minimalEstimateDimension() const'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTVN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE[_ZTVN3g2o10BaseVertexILi3EN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEE]+0xe8): undefined reference to `g2o::OptimizableGraph::Vertex::updateCache()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTV18CurveFittingVertex[_ZTV18CurveFittingVertex]+0x88): undefined reference to `g2o::OptimizableGraph::Vertex::getEstimateData(double*) const'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTV18CurveFittingVertex[_ZTV18CurveFittingVertex]+0x98): undefined reference to `g2o::OptimizableGraph::Vertex::estimateDimension() const'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTV18CurveFittingVertex[_ZTV18CurveFittingVertex]+0xa0): undefined reference to `g2o::OptimizableGraph::Vertex::getMinimalEstimateData(double*) const'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTV18CurveFittingVertex[_ZTV18CurveFittingVertex]+0xb0): undefined reference to `g2o::OptimizableGraph::Vertex::minimalEstimateDimension() const'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTV18CurveFittingVertex[_ZTV18CurveFittingVertex]+0xe8): undefined reference to `g2o::OptimizableGraph::Vertex::updateCache()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTVN3g2o8BaseEdgeILi1EdEE[_ZTVN3g2o8BaseEdgeILi1EdEE]+0x28): undefined reference to `g2o::HyperGraph::Edge::resize(unsigned long)'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTVN3g2o8BaseEdgeILi1EdEE[_ZTVN3g2o8BaseEdgeILi1EdEE]+0x40): undefined reference to `g2o::OptimizableGraph::Edge::setMeasurementData(double const*)'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTVN3g2o8BaseEdgeILi1EdEE[_ZTVN3g2o8BaseEdgeILi1EdEE]+0x48): undefined reference to `g2o::OptimizableGraph::Edge::getMeasurementData(double*) const'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTVN3g2o8BaseEdgeILi1EdEE[_ZTVN3g2o8BaseEdgeILi1EdEE]+0x50): undefined reference to `g2o::OptimizableGraph::Edge::measurementDimension() const'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTVN3g2o8BaseEdgeILi1EdEE[_ZTVN3g2o8BaseEdgeILi1EdEE]+0x58): undefined reference to `g2o::OptimizableGraph::Edge::setMeasurementFromState()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTVN3g2o8BaseEdgeILi1EdEE[_ZTVN3g2o8BaseEdgeILi1EdEE]+0xd8): undefined reference to `g2o::OptimizableGraph::Edge::resolveCaches()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTVN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEEE[_ZTVN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEEE]+0x40): undefined reference to `g2o::OptimizableGraph::Edge::setMeasurementData(double const*)'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTVN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEEE[_ZTVN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEEE]+0x48): undefined reference to `g2o::OptimizableGraph::Edge::getMeasurementData(double*) const'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTVN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEEE[_ZTVN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEEE]+0x50): undefined reference to `g2o::OptimizableGraph::Edge::measurementDimension() const'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTVN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEEE[_ZTVN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEEE]+0x58): undefined reference to `g2o::OptimizableGraph::Edge::setMeasurementFromState()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTVN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEEE[_ZTVN3g2o18BaseFixedSizedEdgeILi1EdJ18CurveFittingVertexEEE]+0xd8): undefined reference to `g2o::OptimizableGraph::Edge::resolveCaches()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTV16CurveFittingEdge[_ZTV16CurveFittingEdge]+0x40): undefined reference to `g2o::OptimizableGraph::Edge::setMeasurementData(double const*)'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTV16CurveFittingEdge[_ZTV16CurveFittingEdge]+0x48): undefined reference to `g2o::OptimizableGraph::Edge::getMeasurementData(double*) const'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTV16CurveFittingEdge[_ZTV16CurveFittingEdge]+0x50): undefined reference to `g2o::OptimizableGraph::Edge::measurementDimension() const'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTV16CurveFittingEdge[_ZTV16CurveFittingEdge]+0x58): undefined reference to `g2o::OptimizableGraph::Edge::setMeasurementFromState()'
/usr/bin/ld: CMakeFiles/g2oCurveFitting.dir/g2oCurveFitting.cpp.o:(.data.rel.ro._ZTV16CurveFittingEdge[_ZTV16CurveFittingEdge]+0xd8): undefined reference to `g2o::OptimizableGraph::Edge::resolveCaches()'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/g2oCurveFitting.dir/build.make:111:g2oCurveFitting] 错误 1
make[1]: *** [CMakeFiles/Makefile2:139:CMakeFiles/g2oCurveFitting.dir/all] 错误 2
make: *** [Makefile:91:all] 错误 2


以及之前安装g2o依赖项时出现的一个小问题:

正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
正在读取状态信息... 完成                 
没有可用的软件包 qt5-default,但是它被其它的软件包引用了。
这可能意味着这个缺失的软件包可能已被废弃,
或者只能在其他发布源中找到

E: 软件包 qt5-default 没有可安装候选


  • 写回答

3条回答 默认 最新

  • 阳光宅男xxb 2023-01-17 12:47
    关注

    看错误是g2o的依赖问题,检查下是否正确安装,在makelist中的依赖引入写法是否正确等。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 1月25日
  • 已采纳回答 1月17日
  • 修改了问题 1月17日
  • 修改了问题 1月17日
  • 展开全部

悬赏问题

  • ¥15 加氢站氢负荷数据集来源
  • ¥15 umi接入sentry遇到问题
  • ¥15 HBuilderX打包H5网页,扫码模块无法使用
  • ¥15 Javascript跳转页面后,无法执行后面代码,如何解决?
  • ¥15 echarts绘制图表
  • ¥15 请教两个关于高德地图定位不准的技术问题
  • ¥15 根据企业名称 对照两个文件 样本筛选/匹配
  • ¥15 Linux环境下CA证书更新问题
  • ¥15 sqlserver语句提取结果以外数据
  • ¥60 微信小程序如何上传QQ聊天文件