I've just built ceres from source (branch 2.0.0), and then "sudo make install", on Ubuntu 20.04.
Now, I'm trying to compile the hello world application with this command:
clang -std=c++14 -I /usr/include/eigen3 -lceres -lglog -lstdc++ -o demo demo.cpp
I get the following linker errors:
/usr/bin/ld: /tmp/demo-29844d.o: in function `main':
demo.cpp:(.text+0x42): undefined reference to `ceres::Problem::Problem()'
/usr/bin/ld: demo.cpp:(.text+0x108): undefined reference to `ceres::Solve(ceres::Solver::Options const&, ceres::Problem*, ceres::Solver::Summary*)'
/usr/bin/ld: demo.cpp:(.text+0x120): undefined reference to `ceres::Solver::Summary::BriefReport[abi:cxx11]() const'
/usr/bin/ld: demo.cpp:(.text+0x214): undefined reference to `ceres::Problem::~Problem()'
/usr/bin/ld: demo.cpp:(.text+0x290): undefined reference to `ceres::Problem::~Problem()'
/usr/bin/ld: /tmp/demo-29844d.o: in function `ceres::internal::ResidualBlock* ceres::Problem::AddResidualBlock<>(ceres::CostFunction*, ceres::LossFunction*, double*)':
demo.cpp:(.text._ZN5ceres7Problem16AddResidualBlockIJEEEPNS_8internal13ResidualBlockEPNS_12CostFunctionEPNS_12LossFunctionEPdDpPT_[_ZN5ceres7Problem16AddResidualBlockIJEEEPNS_8internal13ResidualBlockEPNS_12CostFunctionEPNS_12LossFunctionEPdDpPT_]+0x65): undefined reference to `ceres::Problem::AddResidualBlock(ceres::CostFunction*, ceres::LossFunction*, double* const*, int)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've been programming in C++ for many years, but I can't figure out why the linker can't find the relevant functions in libceres.a. When I dump the symbols from libceres.a, then I see all the necessary symbols in there.
What magic linker/compiler setting am I missing?
Results with GCC are similar.
Thanks