我尝试在 cere-solver 的示例中构建一个只有一个可执行文件helloworld.cc的 ceres-solver 项目,并编写了一个 cmakelist 如下。
cmake_minimum_required(VERSION 3.5)
project(ceres_lab)
find_package(Ceres REQUIRED)
add_executable(ceres_lab main.cpp)
target_link_libraries( ceres_lab Ceres::ceres)
它cmake成功,但是当我尝试制作它时,出现如下错误。
-- Found required Ceres dependency: Eigen version 3.3.9 in /opt/local/include/eigen3
-- Found required Ceres dependency: glog
-- Found required Ceres dependency: gflags
-- Found Ceres version: 2.0.0 installed in: /opt/local with components: [EigenSparse, SparseLinearAlgebraLibrary, LAPACK, SuiteSparse, CXSparse, AccelerateSparse, SchurSpecializations, Multithreading]
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/xietianhao/Desktop/ss_mls/ceres/build
Scanning dependencies of target ceres_lab
[ 50%] Linking CXX executable ceres_lab
ld: warning: directory not found for option '- F/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk/System/Library/Frameworks'
ld: warning: dylib (/opt/local/lib/libglog.0.5.0.dylib) was built for newer macOS version (11.3) than being linked (11.0)
ld: warning: dylib (/opt/local/lib/libsuitesparseconfig.dylib) was built for newer macOS version (11.2) than being linked (11.0)
ld: warning: dylib (/opt/local/lib/libsuitesparseconfig.dylib) was built for newer macOS version (11.2) than being linked (11.0)
Undefined symbols for architecture x86_64:
"google::kLogSiteUninitialized", referenced from:
ceres::Solver::Solve(ceres::Solver::Options const&, ceres::Problem*, ceres::Solver::Summary*) in libceres.a(solver.cc.o)
ceres::(anonymous namespace)::Minimize(ceres::internal::PreprocessedProblem*, ceres::Solver::Summary*)::vlocal__ in libceres.a(solver.cc.o)
ceres::internal::DetectStructure(ceres::internal::CompressedRowBlockStructure const&, int, int*, int*, int*) in libceres.a(detect_structure.cc.o)
ceres::internal::DetectStructure(ceres::internal::CompressedRowBlockStructure const&, int, int*, int*, int*)::vlocal__ in libceres.a(detect_structure.cc.o)
ceres::internal::DetectStructure(ceres::internal::CompressedRowBlockStructure const&, int, int*, int*, int*)::vlocal__ in libceres.a(detect_structure.cc.o)
ceres::internal::DetectStructure(ceres::internal::CompressedRowBlockStructure const&, int, int*, int*, int*)::vlocal__ in libceres.a(detect_structure.cc.o)
ceres::internal::DetectStructure(ceres::internal::CompressedRowBlockStructure const&, int, int*, int*, int*)::vlocal__ in libceres.a(detect_structure.cc.o)
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [ceres_lab] Error 1
make[1]: *** [CMakeFiles/ceres_lab.dir/all] Error 2
make: *** [all] Error 2
我的系统是bigsur 11.4,ceres 2.00。cmakelist 或其他有什么问题吗?谢谢你的时间!