我一直在努力实现 ceres-solver。为了检查我是否做对了,我一直在测试 Ceres 网站上提供的 helloworld.cc 文件。但是,当我运行程序时,我得到一个冗长的错误(显示在底部)
我查看了类似的堆栈溢出问题(在 centOS7 上安装 ceres-solver 并让 helloworld.cc 工作),我知道这个错误与 CMake 列表和编译时找到的链接有关。但是,我仍然对如何告诉编译器在哪里找到解算器的头文件和编译库感到有些困惑。如果你能提供任何资源
- 我应该弄乱哪个cmake文件(ceres包中有很多)
- 我如何告诉编译器在哪里可以找到所需的库,将不胜感激。
我运行这个命令:
g++ -I /usr/include/ -I/usr/include/eigen3 -I/usr/include/glog -l glog -l ceres helloworld.cc
关于我的环境的详细信息:
- Ubuntu 18
- 特征 3.34
- gcc7.5
- 谷神星 1.14
这是我的错误:
/tmp/cc9ybTzk.o: In function `main':
helloworld.cc:(.text+0xde): undefined reference to `google::InitGoogleLogging(char const*)'
helloworld.cc:(.text+0x10d): undefined reference to `ceres::Problem::Problem()'
helloworld.cc:(.text+0x15e): undefined reference to `ceres::Problem::AddResidualBlock(ceres::CostFunction*, ceres::LossFunction*, double*)'
helloworld.cc:(.text+0x183): undefined reference to `ceres::Solver::Summary::Summary()'
helloworld.cc:(.text+0x1a3): undefined reference to `ceres::Solve(ceres::Solver::Options const&, ceres::Problem*, ceres::Solver::Summary*)'
helloworld.cc:(.text+0x1bc): undefined reference to `ceres::Solver::Summary::BriefReport[abi:cxx11]() const'
helloworld.cc:(.text+0x295): undefined reference to `ceres::Problem::~Problem()'
helloworld.cc:(.text+0x30b): undefined reference to `ceres::Problem::~Problem()'
/tmp/cc9ybTzk.o: In function `ceres::AutoDiffCostFunction<CostFunctor, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0>::AutoDiffCostFunction(CostFunctor*)':
helloworld.cc:(.text._ZN5ceres20AutoDiffCostFunctionI11CostFunctorLi1ELi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EEC2EPS1_[_ZN5ceres20AutoDiffCostFunctionI11CostFunctorLi1ELi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EEC5EPS1_]+0xc7): undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int, google::CheckOpString const&)'
helloworld.cc:(.text._ZN5ceres20AutoDiffCostFunctionI11CostFunctorLi1ELi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EEC2EPS1_[_ZN5ceres20AutoDiffCostFunctionI11CostFunctorLi1ELi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EEC5EPS1_]+0xd3): undefined reference to `google::LogMessage::stream()'
helloworld.cc:(.text._ZN5ceres20AutoDiffCostFunctionI11CostFunctorLi1ELi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EEC2EPS1_[_ZN5ceres20AutoDiffCostFunctionI11CostFunctorLi1ELi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EEC5EPS1_]+0xfd): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
helloworld.cc:(.text._ZN5ceres20AutoDiffCostFunctionI11CostFunctorLi1ELi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EEC2EPS1_[_ZN5ceres20AutoDiffCostFunctionI11CostFunctorLi1ELi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EEC5EPS1_]+0x109): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
/tmp/cc9ybTzk.o: In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >* google::MakeCheckOpString<int, int>(int const&, int const&, char const*)':
helloworld.cc:(.text._ZN6google17MakeCheckOpStringIiiEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc]+0x33): undefined reference to `google::base::CheckOpMessageBuilder::CheckOpMessageBuilder(char const*)'
helloworld.cc:(.text._ZN6google17MakeCheckOpStringIiiEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc]+0x5d): undefined reference to `google::base::CheckOpMessageBuilder::ForVar2()'
helloworld.cc:(.text._ZN6google17MakeCheckOpStringIiiEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc]+0x7b): undefined reference to `google::base::CheckOpMessageBuilder::NewString[abi:cxx11]()'
helloworld.cc:(.text._ZN6google17MakeCheckOpStringIiiEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc]+0x8a): undefined reference to `google::base::CheckOpMessageBuilder::~CheckOpMessageBuilder()'
helloworld.cc:(.text._ZN6google17MakeCheckOpStringIiiEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc]+0xad): undefined reference to `google::base::CheckOpMessageBuilder::~CheckOpMessageBuilder()'
/tmp/cc9ybTzk.o: In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >* google::MakeCheckOpString<int, ceres::DimensionType>(int const&, ceres::DimensionType const&, char const*)':
helloworld.cc:(.text._ZN6google17MakeCheckOpStringIiN5ceres13DimensionTypeEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiN5ceres13DimensionTypeEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc]+0x33): undefined reference to `google::base::CheckOpMessageBuilder::CheckOpMessageBuilder(char const*)'
helloworld.cc:(.text._ZN6google17MakeCheckOpStringIiN5ceres13DimensionTypeEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiN5ceres13DimensionTypeEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc]+0x5d): undefined reference to `google::base::CheckOpMessageBuilder::ForVar2()'
helloworld.cc:(.text._ZN6google17MakeCheckOpStringIiN5ceres13DimensionTypeEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiN5ceres13DimensionTypeEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc]+0x7b): undefined reference to `google::base::CheckOpMessageBuilder::NewString[abi:cxx11]()'
helloworld.cc:(.text._ZN6google17MakeCheckOpStringIiN5ceres13DimensionTypeEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiN5ceres13DimensionTypeEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc]+0x8a): undefined reference to `google::base::CheckOpMessageBuilder::~CheckOpMessageBuilder()'
helloworld.cc:(.text._ZN6google17MakeCheckOpStringIiN5ceres13DimensionTypeEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiN5ceres13DimensionTypeEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc]+0xad): undefined reference to `google::base::CheckOpMessageBuilder::~CheckOpMessageBuilder()'
/tmp/cc9ybTzk.o: In function `ceres::internal::AutoDiff<CostFunctor, double, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0>::Differentiate(CostFunctor const&, double const* const*, int, double*, double**)':
helloworld.cc:(.text._ZN5ceres8internal8AutoDiffI11CostFunctordLi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EE13DifferentiateERKS2_PKPKdiPdPSA_[_ZN5ceres8internal8AutoDiffI11CostFunctordLi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EE13DifferentiateERKS2_PKPKdiPdPSA_]+0xb1): undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int, google::CheckOpString const&)'
helloworld.cc:(.text._ZN5ceres8internal8AutoDiffI11CostFunctordLi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EE13DifferentiateERKS2_PKPKdiPdPSA_[_ZN5ceres8internal8AutoDiffI11CostFunctordLi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EE13DifferentiateERKS2_PKPKdiPdPSA_]+0xc0): undefined reference to `google::LogMessage::stream()'
helloworld.cc:(.text._ZN5ceres8internal8AutoDiffI11CostFunctordLi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EE13DifferentiateERKS2_PKPKdiPdPSA_[_ZN5ceres8internal8AutoDiffI11CostFunctordLi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EE13DifferentiateERKS2_PKPKdiPdPSA_]+0xcf): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
helloworld.cc:(.text._ZN5ceres8internal8AutoDiffI11CostFunctordLi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EE13DifferentiateERKS2_PKPKdiPdPSA_[_ZN5ceres8internal8AutoDiffI11CostFunctordLi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EE13DifferentiateERKS2_PKPKdiPdPSA_]+0x3b8): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
/tmp/cc9ybTzk.o: In function `void ceres::internal::Make1stOrderPerturbation<ceres::Jet<double, 1>, double, 1>(int, double const*, ceres::Jet<double, 1>*)':
helloworld.cc:(.text._ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_[_ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_]+0x50): undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int)'
helloworld.cc:(.text._ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_[_ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_]+0x61): undefined reference to `google::LogMessage::stream()'
helloworld.cc:(.text._ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_[_ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_]+0x9e): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
helloworld.cc:(.text._ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_[_ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_]+0xcd): undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int)'
helloworld.cc:(.text._ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_[_ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_]+0xde): undefined reference to `google::LogMessage::stream()'
helloworld.cc:(.text._ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_[_ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_]+0x11b): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
helloworld.cc:(.text._ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_[_ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_]+0x1c2): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
helloworld.cc:(.text._ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_[_ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_]+0x1da): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
/tmp/cc9ybTzk.o: In function `void ceres::internal::Take0thOrderPart<ceres::Jet<double, 1>, double*>(int, ceres::Jet<double, 1> const*, double*)':
helloworld.cc:(.text._ZN5ceres8internal16Take0thOrderPartINS_3JetIdLi1EEEPdEEviPKT_T0_[_ZN5ceres8internal16Take0thOrderPartINS_3JetIdLi1EEEPdEEviPKT_T0_]+0x50): undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int)'
helloworld.cc:(.text._ZN5ceres8internal16Take0thOrderPartINS_3JetIdLi1EEEPdEEviPKT_T0_[_ZN5ceres8internal16Take0thOrderPartINS_3JetIdLi1EEEPdEEviPKT_T0_]+0x61): undefined reference to `google::LogMessage::stream()'
helloworld.cc:(.text._ZN5ceres8internal16Take0thOrderPartINS_3JetIdLi1EEEPdEEviPKT_T0_[_ZN5ceres8internal16Take0thOrderPartINS_3JetIdLi1EEEPdEEviPKT_T0_]+0x9e): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
helloworld.cc:(.text._ZN5ceres8internal16Take0thOrderPartINS_3JetIdLi1EEEPdEEviPKT_T0_[_ZN5ceres8internal16Take0thOrderPartINS_3JetIdLi1EEEPdEEviPKT_T0_]+0xf0): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
/tmp/cc9ybTzk.o: In function `void ceres::internal::Take1stOrderPart<ceres::Jet<double, 1>, double, 0, 1>(int, ceres::Jet<double, 1> const*, double*)':
helloworld.cc:(.text._ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_[_ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_]+0x50): undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int)'
helloworld.cc:(.text._ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_[_ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_]+0x61): undefined reference to `google::LogMessage::stream()'
helloworld.cc:(.text._ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_[_ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_]+0x9e): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
helloworld.cc:(.text._ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_[_ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_]+0xcd): undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int)'
helloworld.cc:(.text._ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_[_ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_]+0xde): undefined reference to `google::LogMessage::stream()'
helloworld.cc:(.text._ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_[_ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_]+0x11b): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
helloworld.cc:(.text._ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_[_ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_]+0x1bb): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
helloworld.cc:(.text._ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_[_ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_]+0x1d3): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
collect2: error: ld returned 1 exit status