I tried to run Ceres library program in example using gcc helloworld.cc
. I checked that all of the libraries are in /usr/local/lib
. I already installed glog
and gflag egien
according to following instructions. I already tried to give explicit path of libraries.
I think I am having linker error but cannt able to figure out how to resolve it.
/tmp/ccTx2jwX.o: In function `main':
helloworld.cc:(.text+0xc4): undefined reference to `google::InitGoogleLogging(char const*)'
helloworld.cc:(.text+0xf2): undefined reference to `ceres::Problem::Problem()'
helloworld.cc:(.text+0x143): undefined reference to `ceres::Problem::AddResidualBlock(ceres::CostFunction*, ceres::LossFunction*, double*)'
helloworld.cc:(.text+0x168): undefined reference to `ceres::Solver::Summary::Summary()'
helloworld.cc:(.text+0x188): undefined reference to `ceres::Solve(ceres::Solver::Options const&, ceres::Problem*, ceres::Solver::Summary*)'
helloworld.cc:(.text+0x1a1): undefined reference to `ceres::Solver::Summary::BriefReport() const'
helloworld.cc:(.text+0x26b): undefined reference to `ceres::Problem::~Problem()'
helloworld.cc:(.text+0x2cd): undefined reference to `ceres::Problem::~Problem()'
/tmp/ccTx2jwX.o: In function `ceres::AutoDiffCostFunction<CostFunctor, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0>::AutoDiffCostFunction(CostFunctor*)':
helloworld.cc:(.text._ZN5ceres20AutoDiffCostFunctionI11CostFunctorLi1ELi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EEC2EPS1_[_ZN5ceres20AutoDiffCostFunctionI11CostFunctorLi1ELi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EEC5EPS1_]+0xb1): undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int, google::CheckOpString const&)'
helloworld.cc:(.text._ZN5ceres20AutoDiffCostFunctionI11CostFunctorLi1ELi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EEC2EPS1_[_ZN5ceres20AutoDiffCostFunctionI11CostFunctorLi1ELi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EEC5EPS1_]+0xbd): undefined reference to `google::LogMessage::stream()'
helloworld.cc:(.text._ZN5ceres20AutoDiffCostFunctionI11CostFunctorLi1ELi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EEC2EPS1_[_ZN5ceres20AutoDiffCostFunctionI11CostFunctorLi1ELi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EEC5EPS1_]+0xe3): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
helloworld.cc:(.text._ZN5ceres20AutoDiffCostFunctionI11CostFunctorLi1ELi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EEC2EPS1_[_ZN5ceres20AutoDiffCostFunctionI11CostFunctorLi1ELi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EEC5EPS1_]+0xef): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
/tmp/ccTx2jwX.o: In function `std::string* google::MakeCheckOpString<int, int>(int const&, int const&, char const*)':
helloworld.cc:(.text._ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc]+0x24): undefined reference to `google::base::CheckOpMessageBuilder::CheckOpMessageBuilder(char const*)'
helloworld.cc:(.text._ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc]+0x4b): undefined reference to `google::base::CheckOpMessageBuilder::ForVar2()'
helloworld.cc:(.text._ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc]+0x66): undefined reference to `google::base::CheckOpMessageBuilder::NewString()'
helloworld.cc:(.text._ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc]+0x75): undefined reference to `google::base::CheckOpMessageBuilder::~CheckOpMessageBuilder()'
helloworld.cc:(.text._ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc]+0x89): undefined reference to `google::base::CheckOpMessageBuilder::~CheckOpMessageBuilder()'
/tmp/ccTx2jwX.o: In function `std::string* google::MakeCheckOpString<int, ceres::DimensionType>(int const&, ceres::DimensionType const&, char const*)':
helloworld.cc:(.text._ZN6google17MakeCheckOpStringIiN5ceres13DimensionTypeEEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiN5ceres13DimensionTypeEEEPSsRKT_RKT0_PKc]+0x24): undefined reference to `google::base::CheckOpMessageBuilder::CheckOpMessageBuilder(char const*)'
helloworld.cc:(.text._ZN6google17MakeCheckOpStringIiN5ceres13DimensionTypeEEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiN5ceres13DimensionTypeEEEPSsRKT_RKT0_PKc]+0x4b): undefined reference to `google::base::CheckOpMessageBuilder::ForVar2()'
helloworld.cc:(.text._ZN6google17MakeCheckOpStringIiN5ceres13DimensionTypeEEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiN5ceres13DimensionTypeEEEPSsRKT_RKT0_PKc]+0x66): undefined reference to `google::base::CheckOpMessageBuilder::NewString()'
helloworld.cc:(.text._ZN6google17MakeCheckOpStringIiN5ceres13DimensionTypeEEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiN5ceres13DimensionTypeEEEPSsRKT_RKT0_PKc]+0x75): undefined reference to `google::base::CheckOpMessageBuilder::~CheckOpMessageBuilder()'
helloworld.cc:(.text._ZN6google17MakeCheckOpStringIiN5ceres13DimensionTypeEEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiN5ceres13DimensionTypeEEEPSsRKT_RKT0_PKc]+0x89): undefined reference to `google::base::CheckOpMessageBuilder::~CheckOpMessageBuilder()'
/tmp/ccTx2jwX.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_]+0x9e): undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int, google::CheckOpString const&)'
helloworld.cc:(.text._ZN5ceres8internal8AutoDiffI11CostFunctordLi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EE13DifferentiateERKS2_PKPKdiPdPSA_[_ZN5ceres8internal8AutoDiffI11CostFunctordLi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EE13DifferentiateERKS2_PKPKdiPdPSA_]+0xad): undefined reference to `google::LogMessage::stream()'
helloworld.cc:(.text._ZN5ceres8internal8AutoDiffI11CostFunctordLi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EE13DifferentiateERKS2_PKPKdiPdPSA_[_ZN5ceres8internal8AutoDiffI11CostFunctordLi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EE13DifferentiateERKS2_PKPKdiPdPSA_]+0xbc): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
helloworld.cc:(.text._ZN5ceres8internal8AutoDiffI11CostFunctordLi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EE13DifferentiateERKS2_PKPKdiPdPSA_[_ZN5ceres8internal8AutoDiffI11CostFunctordLi1ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0ELi0EE13DifferentiateERKS2_PKPKdiPdPSA_]+0x324): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
/tmp/ccTx2jwX.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_]+0x45): undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int)'
helloworld.cc:(.text._ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_[_ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_]+0x56): undefined reference to `google::LogMessage::stream()'
helloworld.cc:(.text._ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_[_ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_]+0x9b): 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_]+0x123): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
helloworld.cc:(.text._ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_[_ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_]+0x1dd): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
helloworld.cc:(.text._ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_[_ZN5ceres8internal24Make1stOrderPerturbationINS_3JetIdLi1EEEdLi1EEEviPKT0_PT_]+0x1fa): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
/tmp/ccTx2jwX.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_]+0x45): undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int)'
helloworld.cc:(.text._ZN5ceres8internal16Take0thOrderPartINS_3JetIdLi1EEEPdEEviPKT_T0_[_ZN5ceres8internal16Take0thOrderPartINS_3JetIdLi1EEEPdEEviPKT_T0_]+0x56): undefined reference to `google::LogMessage::stream()'
helloworld.cc:(.text._ZN5ceres8internal16Take0thOrderPartINS_3JetIdLi1EEEPdEEviPKT_T0_[_ZN5ceres8internal16Take0thOrderPartINS_3JetIdLi1EEEPdEEviPKT_T0_]+0x9b): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
helloworld.cc:(.text._ZN5ceres8internal16Take0thOrderPartINS_3JetIdLi1EEEPdEEviPKT_T0_[_ZN5ceres8internal16Take0thOrderPartINS_3JetIdLi1EEEPdEEviPKT_T0_]+0xf4): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
/tmp/ccTx2jwX.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_]+0x54): undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int)'
helloworld.cc:(.text._ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_[_ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_]+0x65): undefined reference to `google::LogMessage::stream()'
helloworld.cc:(.text._ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_[_ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_]+0xb0): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
helloworld.cc:(.text._ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_[_ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_]+0xe5): undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int)'
helloworld.cc:(.text._ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_[_ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_]+0xf6): undefined reference to `google::LogMessage::stream()'
helloworld.cc:(.text._ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_[_ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_]+0x141): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
helloworld.cc:(.text._ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_[_ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_]+0x1f4): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
helloworld.cc:(.text._ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_[_ZN5ceres8internal16Take1stOrderPartINS_3JetIdLi1EEEdLi0ELi1EEEviPKT_PT0_]+0x211): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
collect2: error: ld returned 1 exit status
on debian I compiled it successfully with the command:
g++ -I /usr/include/ -I /usr/include/eigen3 -I /usr/include/glog -l glog -l ceres helloworld.cc