Giter Club home page Giter Club logo

Comments (10)

dellaert avatar dellaert commented on July 26, 2024

@chrisbeall do you remember the reason we allowed this unsafe behavior? We have optional Matrix& everywhere, but that's non-const. Hoping it's only an issue for const & as that is easier to fix (less of them).

from gtsam.

dellaert avatar dellaert commented on July 26, 2024

Update: if I remove

if(NOT (${Boost_VERSION} LESS 105600))
	message("Ignoring Boost restriction on optional lvalue assignment from rvalues")
	list(APPEND GTSAM_COMPILE_DEFINITIONS_PUBLIC BOOST_OPTIONAL_ALLOW_BINDING_TO_RVALUES BOOST_OPTIONAL_CONFIG_ALLOW_BINDING_TO_RVALUES)
endif()

from cmake files, all tests still succeed, which is surprising. Maybe not fully understanding....

from gtsam.

chrisbeall avatar chrisbeall commented on July 26, 2024

We already had the troublesome usage of boost::optional in the code, and we did not run into trouble until I upgraded to the latest version of Boost which introduced the warnings and BOOST_OPTIONAL_ALLOW_BINDING_TO_RVALUES. Issue: Can't build GTSAM with Boost 1.56 with C++11.

It looks like the code here hasn't really changed since then:

OptionalVariableIndex variableIndex, OptionalOrderingType orderingType) const
{
if(ordering && variableIndex) {
gttic(eliminateMultifrontal);
// Do elimination with given ordering
EliminationTreeType etree(asDerived(), *variableIndex, *ordering);

Why does it work without BOOST_OPTIONAL_ALLOW_BINDING_TO_RVALUES now?

  • I don't recall whether we saw this issue on every platform.
  • Better compiler? (docs mention wrong behavior with reference to integral types, so not relevant here)
  • Boost changes?

Relevant documentation:

from gtsam.

LiShuaixin avatar LiShuaixin commented on July 26, 2024

@dellaert Hi, when I built my own project using CMake, it failed and showed redeclaration error as follow:

In file included from /usr/local/include/gtsam/base/timing.h:118:0,
                 from /usr/local/include/gtsam/inference/VariableIndex-inl.h:21,
                 from /usr/local/include/gtsam/inference/VariableIndex.h:195,
                 from /usr/local/include/gtsam/inference/Ordering.h:24,
                 from /usr/local/include/gtsam/inference/EliminateableFactorGraph.h:26,
                 from /usr/local/include/gtsam/linear/GaussianFactorGraph.h:25,
                 from /usr/local/include/gtsam/nonlinear/NonlinearOptimizerParams.h:24,
                 from /usr/local/include/gtsam/nonlinear/NonlinearOptimizer.h:22,
                 from /usr/local/include/gtsam/nonlinear/LevenbergMarquardtOptimizer.h:23,
                 from /home/lee/experiment/6-phd_program/include/factor_graph_optimization.h:20,
                 from /home/lee/experiment/6-phd_program/include/system.h:40,
                 from /home/lee/experiment/6-phd_program/src/system.cpp:1:
/usr/include/boost/timer/timer.hpp:32:1: error: ‘namespace boost::timer { }’ redeclared as different kind of symbol
 {
 ^
In file included from /usr/include/boost/progress.hpp:22:0,
                 from /home/lee/experiment/6-phd_program/include/surfel_map/synchronized_circular_buffer.h:11,
                 from /home/lee/experiment/6-phd_program/include/local_map.h:24,
                 from /home/lee/experiment/6-phd_program/include/mapping.h:33,
                 from /home/lee/experiment/6-phd_program/include/map_drawer.h:18,
                 from /home/lee/experiment/6-phd_program/include/system.h:34,
                 from /home/lee/experiment/6-phd_program/src/system.cpp:1:
/usr/include/boost/timer.hpp:44:7: note: previous declaration ‘class boost::timer’
 class timer
       ^
In file included from /usr/local/include/gtsam/base/timing.h:118:0,
                 from /usr/local/include/gtsam/inference/VariableIndex-inl.h:21,
                 from /usr/local/include/gtsam/inference/VariableIndex.h:195,
                 from /usr/local/include/gtsam/inference/Ordering.h:24,
                 from /usr/local/include/gtsam/inference/EliminateableFactorGraph.h:26,
                 from /usr/local/include/gtsam/linear/GaussianFactorGraph.h:25,
                 from /usr/local/include/gtsam/nonlinear/NonlinearOptimizerParams.h:24,
                 from /usr/local/include/gtsam/nonlinear/NonlinearOptimizer.h:22,
                 from /usr/local/include/gtsam/nonlinear/LevenbergMarquardtOptimizer.h:23,
                 from /home/lee/experiment/6-phd_program/include/factor_graph_optimization.h:20,
                 from /home/lee/experiment/6-phd_program/include/system.h:40,
                 from /home/lee/experiment/6-phd_program/src/system.cpp:1:
/usr/include/boost/timer/timer.hpp: In member function ‘std::__cxx11::string boost::timer::cpu_timer::format(short int, const string&) const’:
/usr/include/boost/timer/timer.hpp:68:34: error: ‘format’ is not a member of ‘boost::timer’
                         { return ::boost::timer::format(elapsed(), places, format); }
                                  ^
/usr/include/boost/timer/timer.hpp: In member function ‘std::__cxx11::string boost::timer::cpu_timer::format(short int) const’:
/usr/include/boost/timer/timer.hpp:70:34: error: ‘format’ is not a member of ‘boost::timer’
                         { return ::boost::timer::format(elapsed(), places); }
                                  ^
In file included from /usr/local/include/gtsam/inference/VariableIndex-inl.h:21:0,
                 from /usr/local/include/gtsam/inference/VariableIndex.h:195,
                 from /usr/local/include/gtsam/inference/Ordering.h:24,
                 from /usr/local/include/gtsam/inference/EliminateableFactorGraph.h:26,
                 from /usr/local/include/gtsam/linear/GaussianFactorGraph.h:25,
                 from /usr/local/include/gtsam/nonlinear/NonlinearOptimizerParams.h:24,
                 from /usr/local/include/gtsam/nonlinear/NonlinearOptimizer.h:22,
                 from /usr/local/include/gtsam/nonlinear/LevenbergMarquardtOptimizer.h:23,
                 from /home/lee/experiment/6-phd_program/include/factor_graph_optimization.h:20,
                 from /home/lee/experiment/6-phd_program/include/system.h:40,
                 from /home/lee/experiment/6-phd_program/src/system.cpp:1:
/usr/local/include/gtsam/base/timing.h: At global scope:
/usr/local/include/gtsam/base/timing.h:166:21: error: ‘cpu_timer’ in ‘class boost::timer’ does not name a type
       boost::timer::cpu_timer timer_;
                     ^
In file included from /usr/local/include/gtsam/base/timing.h:118:0,
                 from /usr/local/include/gtsam/inference/VariableIndex-inl.h:21,
                 from /usr/local/include/gtsam/inference/VariableIndex.h:195,
                 from /usr/local/include/gtsam/inference/Ordering.h:24,
                 from /usr/local/include/gtsam/inference/EliminateableFactorGraph.h:26,
                 from /usr/local/include/gtsam/linear/GaussianFactorGraph.h:25,
                 from /usr/local/include/gtsam/nonlinear/NonlinearOptimizerParams.h:24,
                 from /usr/local/include/gtsam/nonlinear/NonlinearOptimizer.h:22,
                 from /usr/local/include/gtsam/nonlinear/LevenbergMarquardtOptimizer.h:23,
                 from /home/lee/experiment/6-phd_program/include/factor_graph_optimization.h:20,
                 from /home/lee/experiment/6-phd_program/include/system.h:40,
                 from /home/lee/experiment/6-phd_program/include/mapping.h:22,
                 from /home/lee/experiment/6-phd_program/src/mapping.cpp:1:
/usr/include/boost/timer/timer.hpp:32:1: error: ‘namespace boost::timer { }’ redeclared as different kind of symbol
 {
 ^
In file included from /usr/include/boost/progress.hpp:22:0,
                 from /home/lee/experiment/6-phd_program/include/surfel_map/synchronized_circular_buffer.h:11,
                 from /home/lee/experiment/6-phd_program/include/local_map.h:24,
                 from /home/lee/experiment/6-phd_program/include/map_drawer.h:20,
                 from /home/lee/experiment/6-phd_program/include/system.h:34,
                 from /home/lee/experiment/6-phd_program/include/mapping.h:22,
                 from /home/lee/experiment/6-phd_program/src/mapping.cpp:1:
/usr/include/boost/timer.hpp:44:7: note: previous declaration ‘class boost::timer’
 class timer
       ^
In file included from /usr/local/include/gtsam/base/timing.h:118:0,
                 from /usr/local/include/gtsam/inference/VariableIndex-inl.h:21,
                 from /usr/local/include/gtsam/inference/VariableIndex.h:195,
                 from /usr/local/include/gtsam/inference/Ordering.h:24,
                 from /usr/local/include/gtsam/inference/EliminateableFactorGraph.h:26,
                 from /usr/local/include/gtsam/linear/GaussianFactorGraph.h:25,
                 from /usr/local/include/gtsam/nonlinear/NonlinearOptimizerParams.h:24,
                 from /usr/local/include/gtsam/nonlinear/NonlinearOptimizer.h:22,
                 from /usr/local/include/gtsam/nonlinear/LevenbergMarquardtOptimizer.h:23,
                 from /home/lee/experiment/6-phd_program/include/factor_graph_optimization.h:20,
                 from /home/lee/experiment/6-phd_program/include/system.h:40,
                 from /home/lee/experiment/6-phd_program/include/mapping.h:22,
                 from /home/lee/experiment/6-phd_program/src/mapping.cpp:1:
/usr/include/boost/timer/timer.hpp: In member function ‘std::__cxx11::string boost::timer::cpu_timer::format(short int, const string&) const’:
/usr/include/boost/timer/timer.hpp:68:34: error: ‘format’ is not a member of ‘boost::timer’
                         { return ::boost::timer::format(elapsed(), places, format); }
                                  ^
/usr/include/boost/timer/timer.hpp: In member function ‘std::__cxx11::string boost::timer::cpu_timer::format(short int) const’:
/usr/include/boost/timer/timer.hpp:70:34: error: ‘format’ is not a member of ‘boost::timer’
                         { return ::boost::timer::format(elapsed(), places); }
                                  ^
In file included from /usr/local/include/gtsam/inference/VariableIndex-inl.h:21:0,
                 from /usr/local/include/gtsam/inference/VariableIndex.h:195,
                 from /usr/local/include/gtsam/inference/Ordering.h:24,
                 from /usr/local/include/gtsam/inference/EliminateableFactorGraph.h:26,
                 from /usr/local/include/gtsam/linear/GaussianFactorGraph.h:25,
                 from /usr/local/include/gtsam/nonlinear/NonlinearOptimizerParams.h:24,
                 from /usr/local/include/gtsam/nonlinear/NonlinearOptimizer.h:22,
                 from /usr/local/include/gtsam/nonlinear/LevenbergMarquardtOptimizer.h:23,
                 from /home/lee/experiment/6-phd_program/include/factor_graph_optimization.h:20,
                 from /home/lee/experiment/6-phd_program/include/system.h:40,
                 from /home/lee/experiment/6-phd_program/include/mapping.h:22,
                 from /home/lee/experiment/6-phd_program/src/mapping.cpp:1:
/usr/local/include/gtsam/base/timing.h: At global scope:
/usr/local/include/gtsam/base/timing.h:166:21: error: ‘cpu_timer’ in ‘class boost::timer’ does not name a type
       boost::timer::cpu_timer timer_;
                     ^

The building environment is Ubuntu 16.04 with boost 1.58. I'm not familiar with boost, so could you please take a look on this issue.

from gtsam.

ProfFan avatar ProfFan commented on July 26, 2024

Getting this into 4.1.

from gtsam.

ProfFan avatar ProfFan commented on July 26, 2024

#121

from gtsam.

ProfFan avatar ProfFan commented on July 26, 2024

I think as #156 is merged this can be closed?

from gtsam.

dellaert avatar dellaert commented on July 26, 2024

I think we still need to tell cmake about having boost disallow it, I did not see that in the PR. Would be nice as that is frequently the only warning.

from gtsam.

ProfFan avatar ProfFan commented on July 26, 2024

Great, I'll make a PR to remove the flag.

from gtsam.

ProfFan avatar ProfFan commented on July 26, 2024

Closed by #201.

from gtsam.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.