RainerKuemmerle / g2o

g2o: A General Framework for Graph Optimization
3.04k stars 1.1k forks source link

Undefined symbols for architecture x86_64 using Macos 10.12.6 #210

Open Kay1794 opened 6 years ago

Kay1794 commented 6 years ago

Hi,

I met this problem when I built a project using g2o.

screen shot 2017-09-26 at 21 17 23

[100%] Linking CXX executable ../../../bin/sample_app Undefined symbols for architecture x86_64: "g2o::csparse_extension::cs_cholsolsymb(cs_di_sparse const*, double*, cs_di_symbolic const*, double*, int*)", referenced from: g2o::LinearSolverCSparse<Eigen::Matrix<double, 7, 7, 0, 7, 7> >::solve(g2o::SparseBlockMatrix<Eigen::Matrix<double, 7, 7, 0, 7, 7> > const&, double*, double*) in liblsd_slam.a(key_frame_graph.cc.o) "g2o::csparse_extension::writeCs2Octave(char const*, cs_di_sparse const*, bool)", referenced from: g2o::LinearSolverCSparse<Eigen::Matrix<double, 7, 7, 0, 7, 7> >::solve(g2o::SparseBlockMatrix<Eigen::Matrix<double, 7, 7, 0, 7, 7> > const&, double*, double*) in liblsd_slam.a(key_frame_graph.cc.o) "g2o::csparse_extension::cs_chol_workspace(cs_di_sparse const*, cs_di_symbolic const*, int*, double*)", referenced from: g2o::LinearSolverCSparse<Eigen::Matrix<double, 7, 7, 0, 7, 7> >::solveBlocks(double**&, g2o::SparseBlockMatrix<Eigen::Matrix<double, 7, 7, 0, 7, 7> > const&) in liblsd_slam.a(key_frame_graph.cc.o) g2o::LinearSolverCSparse<Eigen::Matrix<double, 7, 7, 0, 7, 7> >::solvePattern(g2o::SparseBlockMatrix<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, std::__1::vector<std::__1::pair<int, int>, std::__1::allocator<std::__1::pair<int, int> > > const&, g2o::SparseBlockMatrix<Eigen::Matrix<double, 7, 7, 0, 7, 7> > const&) in liblsd_slam.a(key_frame_graph.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]: *** [../bin/sample_app] Error 1 make[1]: *** [apps/slam/CMakeFiles/sample_app.dir/all] Error 2 make: *** [all] Error 2 My cmake flags are -DCMAKE_BUILD_TYPE=Release -DBUILD_CSPARSE=ON Not sure if it is a link problem using g2o on mac

Does anyone have the same problem?

sjulier commented 6 years ago

One idea is that you seem to be linking with a static library (liblsd_slam.a). This won't, automatically, pull in all the dependent libraries. Can you run:

make VERBOSE=1

and see if it's trying to link in the csparse libraries at all? If not, you'll have to manually include csparse in the target_link_libraries.

(There is a branch on github which uses new-style cmake options which should hopefully address this problem.)

niebayes commented 4 years ago
  1. pull the latest repo of g2o from Github.
  2. compile it.
  3. find_package()
  4. include_directories()
  5. target_link_libraries() --- NOTICE: G2O has two libraries ${G2O_CORE_LIBRARY} and ${G2O_STUFF_LIBRARY}, instead of the ordinary one ${G2O_LIBRARIES}. You need to specify both of them in this command.
wbrennan899 commented 4 years ago
  • pull the latest repo of g2o from Github.
  • compile it.
  • find_package()
  • include_directories()
  • target_link_libraries() --- NOTICE: G2O has two libraries ${G2O_CORE_LIBRARY} and ${G2O_STUFF_LIBRARY}, instead of the ordinary one ${G2O_LIBRARIES}. You need to specify both of them in this command.

@niebayes Could you please provide a little more detail on how to implement this? Do you think it will solve the issue I just posted? https://github.com/RainerKuemmerle/g2o/issues/423