Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor the build system -- use exported cmake targets instead of ma… #35

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from

Conversation

feixh
Copy link
Collaborator

@feixh feixh commented Feb 20, 2022

The current build system manually specifies path to the include/library directories. This is not portable.
For instance, on Fedora, the shared libraries (of the 3rd dependencies) will be installed in directory lib64 instead of lib.

In this PR, I removed some of the hardcoded paths, and used find_package and linked XIVO's targets against targets exported by the installed third-party libraries.

…nually setting headers and libs for the dependencies

add_library(xest STATIC
add_library(xest SHARED
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason for building a shared library instead of a static library?

${PROJECT_SOURCE_DIR}/thirdparty/pnp/build
${PROJECT_SOURCE_DIR}/thirdparty/ceres-solver/lib
/usr/local/lib
find_package(OpenCV REQUIRED PATHS ${THIRD_PARTY_DIR}/opencv/install)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add the following above this block so that CMake doesn't accidentally link to a version that was installed onto the OS or exported from another project:

+set(Eigen3_DIR ${THIRD_PARTY_DIR}/eigen/share/eigen3/cmake)
+set(Ceres_DIR ${THIRD_PARTY_DIR}/ceres-solver/lib/cmake/Ceres)
+set(gflags_DIR ${THIRD_PARTY_DIR}/gflags/lib/cmake/gflags)
+set(glog_DIR ${THIRD_PARTY_DIR}/glog/lib/cmake/glog)
+set(gtest_DIR ${THIRD_PARTY_DIR}/googletest/lib/cmake/GTest)
+set(jsoncpp_DIR ${THIRD_PARTY_DIR}/jsoncpp/lib/cmake/jsoncpp)
+set(Pangolin_DIR ${THIRD_PARTY_DIR}/Pangolin/lib/cmake/Pangolin)
+set(DBoW2_DIR ${THIRD_PARTY_DIR}/DBoW2/lib/cmake/DBoW2)

@stephanietsuei
Copy link
Collaborator

stephanietsuei commented Feb 21, 2022

At the moment, I'm getting the following linker error on Ubuntu 20.04 (lab machine):

/usr/bin/ld: ../thirdparty/ceres-solver/lib/libceres.a(eigensparse.cc.o): in function `Eigen::internal::Assignment<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Product<Eigen::PermutationMatrix<-1, -1, int>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, 2>, Eigen::internal::assign_op<double, double>, Eigen::internal::Dense2Dense, void>::run(Eigen::Matrix<double, -1, 1, 0, -1, 1>&, Eigen::Product<Eigen::PermutationMatrix<-1, -1, int>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, 2> const&, Eigen::internal::assign_op<double, double> const&) [clone .isra.0]':
eigensparse.cc:(.text+0x33c): undefined reference to `Eigen::internal::aligned_malloc(unsigned long)'

On my laptop (Manjaro Linux), I get a segmentation fault at a matrix multiplication. It seems to be something related to data alignment at the processor level, but I haven't found a fix yet. gdb gives me this backtrace:

#0  Eigen::internal::dense_assignment_loop<Eigen::internal::generic_dense_assignment_kernel<Eigen::internal::evaluator<Eigen::Matrix<double, -1, 1, 0, -1, 1> >, Eigen::internal::evaluator<Eigen::Matrix<double, -1, 1, 0, -1, 1> >, Eigen::internal::assign_op<double, double>, 0>, 3, 0>::run(Eigen::internal::generic_dense_assignment_kernel<Eigen::internal::evaluator<Eigen::Matrix<double, -1, 1, 0, -1, 1> >, Eigen::internal::evaluator<Eigen::Matrix<double, -1, 1, 0, -1, 1> >, Eigen::internal::assign_op<double, double>, 0>&) (kernel=<synthetic pointer>...)
    at /home/stephanie/Code/xivo/thirdparty/eigen/include/eigen3/Eigen/src/Core/AssignEvaluator.h:416
#1  Eigen::internal::call_dense_assignment_loop<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::internal::assign_op<double, double> >(Eigen::Matrix<double, -1, 1, 0, -1, 1>&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, Eigen::internal::assign_op<double, double> const&) (func=<optimized out>, src=<synthetic pointer>..., dst=...)
    at /home/stephanie/Code/xivo/thirdparty/eigen/include/eigen3/Eigen/src/Core/AssignEvaluator.h:741
#2  Eigen::internal::Assignment<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::internal::assign_op<double, double>, Eigen::internal::Dense2Dense, void>::run(Eigen::Matrix<double, -1, 1, 0, -1, 1>&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, Eigen::internal::assign_op<double, double> const&) (func=<optimized out>, src=<synthetic pointer>..., dst=...)
    at /home/stephanie/Code/xivo/thirdparty/eigen/include/eigen3/Eigen/src/Core/AssignEvaluator.h:879
#3  Eigen::internal::call_assignment_no_alias<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::internal::assign_op<double, double> >(Eigen::Matrix<double, -1, 1, 0, -1, 1>&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, Eigen::internal::assign_op<double, double> const&) (func=<optimized out>, src=<synthetic pointer>..., dst=...)
    at /home/stephanie/Code/xivo/thirdparty/eigen/include/eigen3/Eigen/src/Core/AssignEvaluator.h:836
#4  Eigen::internal::call_assignment<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Product<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0>, Eigen::internal::assign_op<double, double> >(Eigen::Matrix<double, -1, 1, 0, -1, 1>&, Eigen::Product<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0> const&, Eigen::internal::assign_op<double, double> const&, Eigen::internal::enable_if<Eigen::internal::evaluator_assume_aliasing<Eigen::Product<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0>, Eigen::internal::evaluator_traits<Eigen::Product<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0> >::Shape>::value, void*>::type) (func=<optimized out>, src=<optimized out>, dst=...)
    at /home/stephanie/Code/xivo/thirdparty/eigen/include/eigen3/Eigen/src/Core/AssignEvaluator.h:797
#5  Eigen::internal::call_assignment<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Product<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0> >(Eigen::Matrix<double, -1, 1, 0, -1, 1>&, Eigen::Product<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0> const&) (src=<optimized out>, dst=...)
    at /home/stephanie/Code/xivo/thirdparty/eigen/include/eigen3/Eigen/src/Core/AssignEvaluator.h:782
#6  Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >::_set<Eigen::Product<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0> >(Eigen::DenseBase<Eigen::Product<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0> > c--Type <RET> for more, q to quit, c to continue without paging--
onst&) (other=<optimized out>, this=0x5555c17f8e80)
    at /home/stephanie/Code/xivo/thirdparty/eigen/include/eigen3/Eigen/src/Core/PlainObjectBase.h:714
#7  Eigen::Matrix<double, -1, 1, 0, -1, 1>::operator=<Eigen::Product<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0> >(Eigen::DenseBase<Eigen::Product<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0> > const&)
    (other=<optimized out>, this=0x5555c17f8e80) at /home/stephanie/Code/xivo/thirdparty/eigen/include/eigen3/Eigen/src/Core/Matrix.h:225
#8  xivo::Estimator::UpdateJosephForm() (this=0x5555c17f8be0) at /home/stephanie/Code/xivo/src/estimator.cpp:972
#9  0x00007ffff7ed61dc in xivo::Estimator::Update() (this=this@entry=0x5555c17f8be0) at /home/stephanie/Code/xivo/src/update.cpp:152
#10 0x00007ffff7ec4933 in xivo::Estimator::ProcessTracks(std::chrono::duration<long, std::ratio<1l, 1000000000l> > const&, std::__cxx11::list<xivo::Feature*, std::allocator<xivo::Feature*> >&) (this=this@entry=0x5555c17f8be0, ts=..., tracks=std::__cxx11::list = {...})
    at /home/stephanie/Code/xivo/src/manager.cpp:202
#11 0x00007ffff7e700f6 in xivo::Estimator::VisualMeasInternal(std::chrono::duration<long, std::ratio<1l, 1000000000l> > const&, cv::Mat const&)
    (this=0x5555c17f8be0, ts=..., img=<optimized out>) at /home/stephanie/Code/xivo/src/estimator.cpp:945
#12 0x00007ffff7e6b5ac in xivo::Estimator::MaintainBuffer() (this=0x5555c17f8be0) at /home/stephanie/Code/xivo/src/estimator.cpp:880
#13 xivo::Estimator::MaintainBuffer() (this=0x5555c17f8be0) at /home/stephanie/Code/xivo/src/estimator.cpp:867
#14 0x0000555555578df6 in main(int, char**) (argc=<optimized out>, argv=<optimized out>) at /home/stephanie/Code/xivo/src/app/vio.cpp:92

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants