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

Failing examples on 20.04 #772

Closed
bhchiang opened this issue May 29, 2021 · 14 comments
Closed

Failing examples on 20.04 #772

bhchiang opened this issue May 29, 2021 · 14 comments

Comments

@bhchiang
Copy link

Ubuntu 20.04 - built gtsam from the develop branch earlier today.

When running the examples (specifically the StereoVO one here), I'm getting an undefined symbol error:

./main: symbol lookup error: ./main: undefined symbol: _ZNK5gtsam6Factor9printKeysERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt8functionIFS6_mEE

I found out what the symbol represents, but not sure how to fix it:

(base) bryan@ito:~/work/play-gtsam$ c++filt _ZNK5gtsam6Factor9printKeysERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt8functionIFS6_mEE
gtsam::Factor::printKeys(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::function<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > (unsigned long)> const&) const

Any suggestions would be appreciated!

Here's a minimal setup to reproduce (it builds but doesn't run):

Makefile:

all: main.cpp
	g++ main.cpp \
	-std=c++11 \
	-I /usr/include/eigen3 \
	-lboost_system -lboost_filesystem \
	-lgtsam \
	-ltbb \
	-o main

clear:
	rm -rf main

main.cpp:

/* ----------------------------------------------------------------------------

 * GTSAM Copyright 2010, Georgia Tech Research Corporation,
 * Atlanta, Georgia 30332-0415
 * All Rights Reserved
 * Authors: Frank Dellaert, et al. (see THANKS for the full author list)

 * See LICENSE for the license information

 * -------------------------------------------------------------------------- */

/**
 * @file StereoVOExample.cpp
 * @brief A stereo visual odometry example
 * @date May 25, 2014
 * @author Stephen Camp
 */

/**
 * A 3D stereo visual odometry example
 *  - robot starts at origin
 *  -moves forward 1 meter
 *  -takes stereo readings on three landmarks
 */

#include <gtsam/geometry/Pose3.h>
#include <gtsam/geometry/Cal3_S2Stereo.h>
#include <gtsam/nonlinear/Values.h>
#include <gtsam/nonlinear/NonlinearEquality.h>
#include <gtsam/nonlinear/NonlinearFactorGraph.h>
#include <gtsam/nonlinear/LevenbergMarquardtOptimizer.h>
#include <gtsam/slam/StereoFactor.h>

using namespace std;
using namespace gtsam;

int main(int argc, char **argv)
{
    // create graph object, add first pose at origin with key '1'
    NonlinearFactorGraph graph;
    Pose3 first_pose;
    graph.emplace_shared<NonlinearEquality<Pose3>>(1, Pose3());

    // create factor noise model with 3 sigmas of value 1
    const auto model = noiseModel::Isotropic::Sigma(3, 1);
    // create stereo camera calibration object with .2m between cameras
    const Cal3_S2Stereo::shared_ptr K(
        new Cal3_S2Stereo(1000, 1000, 0, 320, 240, 0.2));

    //create and add stereo factors between first pose (key value 1) and the three landmarks
    graph.emplace_shared<GenericStereoFactor<Pose3, Point3>>(StereoPoint2(520, 480, 440), model, 1, 3, K);
    graph.emplace_shared<GenericStereoFactor<Pose3, Point3>>(StereoPoint2(120, 80, 440), model, 1, 4, K);
    graph.emplace_shared<GenericStereoFactor<Pose3, Point3>>(StereoPoint2(320, 280, 140), model, 1, 5, K);

    //create and add stereo factors between second pose and the three landmarks
    graph.emplace_shared<GenericStereoFactor<Pose3, Point3>>(StereoPoint2(570, 520, 490), model, 2, 3, K);
    graph.emplace_shared<GenericStereoFactor<Pose3, Point3>>(StereoPoint2(70, 20, 490), model, 2, 4, K);
    graph.emplace_shared<GenericStereoFactor<Pose3, Point3>>(StereoPoint2(320, 270, 115), model, 2, 5, K);

    // create Values object to contain initial estimates of camera poses and
    // landmark locations
    Values initial_estimate;

    // create and add iniital estimates
    initial_estimate.insert(1, first_pose);
    initial_estimate.insert(2, Pose3(Rot3(), Point3(0.1, -0.1, 1.1)));
    initial_estimate.insert(3, Point3(1, 1, 5));
    initial_estimate.insert(4, Point3(-1, 1, 5));
    initial_estimate.insert(5, Point3(0, -0.5, 5));

    // create Levenberg-Marquardt optimizer for resulting factor graph, optimize
    LevenbergMarquardtOptimizer optimizer(graph, initial_estimate);
    Values result = optimizer.optimize();

    result.print("Final result:\n");

    return 0;
}
@bhchiang
Copy link
Author

Checking out 4.0.3 and building that from source worked instead.

@bhchiang
Copy link
Author

Confirmed that Cython examples also work on 4.0.3.

@ProfFan
Copy link
Collaborator

ProfFan commented May 29, 2021

Note that you should NOT use a Makefile for GTSAM-related projects if you are not super familiar with GTSAM internals.

We recommend you use CMake and include GTSAM with find_package.

If you still want to know what went wrong, please first build with CMake, and then make VERBOSE=1 to get the correct g++ arguments.

@bhchiang
Copy link
Author

The Makefile was just for the minimal reproduction.

The error occurs on the official examples under build/examples when I built GTSAM on the current develop branch.

@varunagrawal
Copy link
Collaborator

I built the examples on my Ubuntu 20.04 machine and I cannot reproduce the error.

@bryanhpchiang can you please try using the CMake based build? I suspect some linking is not happening correctly.

cmake -DGTSAM_BUILD_EXAMPLES_ALWAYS=ON .. && make -j4 && ./examples/StereoVOExample

@bhchiang
Copy link
Author

bhchiang commented May 30, 2021

For sure, just tried building the develop branch again. The specific commit is 1011055007bfbbe0f7f4263e3963d0c97fd7ca33.

Here's what I ran (I use the Python bindings):

cmake -DGTSAM_BUILD_EXAMPLES_ALWAYS=ON -DGTSAM_BUILD_PYTHON=1 -DGTSAM_PYTHON_VERSION=3.8.6 ..
make -j4

Result:

(base) bryan@ito:~/work/gtsam/build$ ./examples/StereoVOExample
./examples/StereoVOExample: symbol lookup error: ./examples/StereoVOExample: undefined symbol: _ZNK5gtsam6Factor9printKeysERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt8functionIFS6_mEE

Here's the full result from cmake:

-- The CXX compiler identification is GNU 9.3.0
-- The C compiler identification is GNU 9.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Performing Test COMPILER_HAS_WSUGGEST_OVERRIDE
-- Performing Test COMPILER_HAS_WSUGGEST_OVERRIDE - Success
-- Performing Test COMPILER_HAS_WMISSING_OVERRIDE
-- Performing Test COMPILER_HAS_WMISSING_OVERRIDE - Failed
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found suitable version "1.71.0", minimum required is "1.58") found components: serialization system filesystem thread program_options date_time timer chrono regex 
-- Found Eigen version: 3.3.7
-- GTSAM_POSE3_EXPMAP=ON, enabling GTSAM_ROT3_EXPMAP as well
-- Found MKL: /home/bryan/miniconda3/include  
-- Found OpenMP_C: -fopenmp (found version "4.5") 
-- Found OpenMP_CXX: -fopenmp (found version "4.5") 
-- Found OpenMP: TRUE (found version "4.5")  
-- Found TBB: /usr/include (found suitable version "2020.1", minimum required is "4.4") found components: tbb tbbmalloc 
-- Building 3rdparty
-- Looking for execinfo.h
-- Looking for execinfo.h - found
-- Looking for getline
-- Looking for getline - found
-- checking for thread-local storage - found
-- Could NOT find GeographicLib (missing: GeographicLib_LIBRARY_DIRS GeographicLib_LIBRARIES GeographicLib_INCLUDE_DIRS) 
-- Building base
-- Building geometry
-- Building inference
-- Building symbolic
-- Building discrete
-- Building linear
-- Building nonlinear
-- Building sam
-- Building sfm
-- Building slam
-- Building navigation
-- GTSAM Version: 4.1.0
-- Install prefix: /usr/local
-- Building GTSAM - shared: ON
-- Building base_unstable
-- Building geometry_unstable
-- Building linear_unstable
-- Building discrete_unstable
-- Building dynamics_unstable
-- Building nonlinear_unstable
-- Building slam_unstable
-- Building partition_unstable
-- GTSAM_UNSTABLE Version: 4.1.0
-- Install prefix: /usr/local
-- Found Python: /home/bryan/miniconda3/bin/python3.8 (found suitable exact version "3.8.6") found components: Interpreter Development Development.Module Development.Embed 
-- gtwrap Package config : /usr/local/lib/cmake/gtwrap
-- gtwrap version        : 1.0
-- gtwrap CMake path     : /usr/local/lib/cmake/gtwrap
-- gtwrap library path   : /usr/local/lib/gtwrap
-- gtwrap binary path    : /usr/local/bin/gtwrap
-- gtwrap header path    : /usr/local/include/gtwrap
-- Checking Python Version
-- Setting Python version for wrapper
-- pybind11 v2.6.0 dev1
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- Wrote /home/bryan/work/gtsam/build/GTSAMConfig.cmake
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
-- ===============================================================
-- ================  Configuration Options  ======================
--  CMAKE_CXX_COMPILER_ID type                       : GNU
--  CMAKE_CXX_COMPILER_VERSION                       : 9.3.0
--  CMake version                                    : 3.18.2
--  CMake generator                                  : Unix Makefiles
--  CMake build tool                                 : /usr/bin/make
-- Build flags                                               
--  Build Tests                                      : Enabled
--  Build examples with 'make all'                   : Enabled
--  Build timing scripts with 'make all'             : Disabled
--  Build shared GTSAM libraries                     : Enabled
--  Put build type in library name                   : Enabled
--  Build libgtsam_unstable                          : Enabled
--  Build GTSAM unstable Python                      : Enabled
--  Build MATLAB Toolbox for unstable                : Disabled
--  Build for native architecture                    : Enabled
--  Build type                                       : Release
--  C compilation flags                              :  -O3 -DNDEBUG
--  C++ compilation flags                            :  -O3 -DNDEBUG
--  GTSAM_COMPILE_FEATURES_PUBLIC                    : cxx_std_11
--  GTSAM_COMPILE_OPTIONS_PUBLIC                     : -march=native
--  GTSAM_COMPILE_DEFINITIONS_PUBLIC                 : 
--  GTSAM_COMPILE_OPTIONS_PUBLIC_DEBUG               : 
--  GTSAM_COMPILE_DEFINITIONS_PUBLIC_DEBUG           : 
--  GTSAM_COMPILE_OPTIONS_PUBLIC_RELEASE             : 
--  GTSAM_COMPILE_DEFINITIONS_PUBLIC_RELEASE         : 
--  GTSAM_COMPILE_OPTIONS_PUBLIC_TIMING              : 
--  GTSAM_COMPILE_DEFINITIONS_PUBLIC_TIMING          : 
--  GTSAM_COMPILE_OPTIONS_PUBLIC_PROFILING           : 
--  GTSAM_COMPILE_DEFINITIONS_PUBLIC_PROFILING       : 
--  GTSAM_COMPILE_OPTIONS_PUBLIC_RELWITHDEBINFO      : 
--  GTSAM_COMPILE_DEFINITIONS_PUBLIC_RELWITHDEBINFO  : 
--  GTSAM_COMPILE_OPTIONS_PUBLIC_MINSIZEREL          : 
--  GTSAM_COMPILE_DEFINITIONS_PUBLIC_MINSIZEREL      : 
--  Use System Eigen                                 : OFF (Using version: 3.3.7)
--  Use Intel TBB                                    : Yes (Version: 2020.1)
--  Eigen will use MKL                               : MKL found but GTSAM_WITH_EIGEN_MKL is disabled
--  Eigen will use MKL and OpenMP                    : OpenMP found but GTSAM_WITH_EIGEN_MKL is disabled
--  Default allocator                                : TBB
--  Cheirality exceptions enabled                    : YES
--  Build with ccache                                : No
-- Packaging flags
--  CPack Source Generator                           : TGZ
--  CPack Generator                                  : TGZ
-- GTSAM flags                                               
--  Quaternions as default Rot3                      : Disabled
--  Runtime consistency checking                     : Disabled
--  Rot3 retract is full ExpMap                      : Enabled
--  Pose3 retract is full ExpMap                     : Enabled
--  Allow features deprecated in GTSAM 4.1           : Enabled
--  Metis-based Nested Dissection                    : Enabled
--  Use tangent-space preintegration                 : Enabled
-- MATLAB toolbox flags
--  Install MATLAB toolbox                           : Disabled
-- Python toolbox flags                                      
--  Build Python module with pybind                  : Enabled
--  Python version                                   : 3.8.6
-- ===============================================================
-- Configuring done
-- Generating done
-- Build files have been written to: /home/bryan/work/gtsam/build

@varunagrawal
Copy link
Collaborator

Okay, I've been using Clang-9 rather than GCC. Let me switch as get back to you. I don't think there is any other major difference (I use Boost 1.72.0).

@varunagrawal
Copy link
Collaborator

Interesting. It works on GCC for me as well, I'm a bit confused at this point.

@ProfFan
Copy link
Collaborator

ProfFan commented May 30, 2021

I think it's something related to multiple GTSAM versions. 5 cents you have a global install of GTSAM that is not the same version as the source.

@varunagrawal
Copy link
Collaborator

That's a great suggestion. Perhaps some of your 4.0.3 install is still lingering in your system.

@bhchiang
Copy link
Author

bhchiang commented May 30, 2021

Got it - that definitely makes sense since I might have installed GTSAM before with apt-get.

  • How would I check for and remove a global install of GTSAM?

By this I mean should I write a short C++ program to see what version of GTSAM is being used?

  • Why would having multiple versions cause an error - is it the dynamic linking to the GTSAM .so file?

Thanks!

@ProfFan
Copy link
Collaborator

ProfFan commented May 31, 2021

  1. If you installed with apt-get, uninstall
  2. Search for libgtsam.xxxxx in /usr/lib and /usr/local/lib, make sure there is none
  3. make sure there is no /usr/include/gtsam and /usr/local/include/gtsam
  4. Yes, it's a dynamic library, for details see ldconfig documentation.

@varunagrawal
Copy link
Collaborator

Also check out apt purge

@ProfFan
Copy link
Collaborator

ProfFan commented Jun 3, 2021

Closing as stale

@ProfFan ProfFan closed this as completed Jun 3, 2021
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

No branches or pull requests

3 participants