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

Unable to include LogStream with CasAdi #2420

Closed
Giulero opened this issue Nov 25, 2020 · 3 comments
Closed

Unable to include LogStream with CasAdi #2420

Giulero opened this issue Nov 25, 2020 · 3 comments

Comments

@Giulero
Copy link
Contributor

Giulero commented Nov 25, 2020

Describe the bug

If I include

#include <casadi/casadi.hpp>
#include <yarp/os/LogStream.h>

the following error occurs while compiles:

In file included from /home/giuseppe/robotology-superbuild/build/install/include/yarp/os/all.h:26,
                 from /home/giuseppe/Desktop/IronCub/element_transition-maneouvers/modules/point_mass_opt_test/pointMassOptimizer/include/Solver.h:13,
                 from /home/giuseppe/Desktop/IronCub/element_transition-maneouvers/modules/point_mass_opt_test/pointMassOptimizer/src/Solver.cpp:9:
/home/giuseppe/robotology-superbuild/build/install/include/yarp/os/LogStream.h:238:22: error: redefinition of ‘template<class T> std::ostream& std::operator<<(std::ostream&, const std::vector<T>&)’
  238 | inline std::ostream& std::operator<<(std::ostream& os, const std::vector<T>& t)
      |                      ^~~
In file included from /home/giuseppe/git_repos/casadi/build/install/include/casadi/core/matrix_fwd.hpp:29,
                 from /home/giuseppe/git_repos/casadi/build/install/include/casadi/core/sx_elem.hpp:33,
                 from /home/giuseppe/git_repos/casadi/build/install/include/casadi/core/core.hpp:30,
                 from /home/giuseppe/git_repos/casadi/build/install/include/casadi/casadi.hpp:29,
                 from /home/giuseppe/Desktop/IronCub/element_transition-maneouvers/modules/point_mass_opt_test/pointMassOptimizer/include/Solver.h:12,
                 from /home/giuseppe/Desktop/IronCub/element_transition-maneouvers/modules/point_mass_opt_test/pointMassOptimizer/src/Solver.cpp:9:
/home/giuseppe/git_repos/casadi/build/install/include/casadi/core/casadi_misc.hpp:430:12: note: ‘template<class T> std::ostream& std::operator<<(std::ostream&, const std::vector<T>&)’ previously declared here
  430 |   ostream& operator<<(ostream& stream, const vector<T>& v) {
      |            ^~~~~~~~
make[2]: *** [modules/point_mass_opt_test/pointMassOptimizer/CMakeFiles/TrajOptSolver.dir/build.make:83: modules/point_mass_opt_test/pointMassOptimizer/CMakeFiles/TrajOptSolver.dir/src/Solver.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:361: modules/point_mass_opt_test/pointMassOptimizer/CMakeFiles/TrajOptSolver.dir/all] Error 2
make: *** [Makefile:150: all] Error 2

Configuration (please complete the following information):

  • OS: Ubuntu 20.04
  • yarp version: 3.4
  • compiler: gcc version 9.3.0
@GiulioRomualdi
Copy link
Member

GiulioRomualdi commented Nov 25, 2020

Unfortunately, both yarp and casadi expand std namespace

casadi

https://github.com/casadi/casadi/blob/fadc86444f3c7ab824dc3f2d91d4c0cfe7f9dad5/casadi/core/casadi_misc.hpp#L428-L433

yarp

namespace std {
template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& t);
}

Probably the fastest solution avoids using LogStream in your application

cc @traversaro

@traversaro
Copy link
Member

Thanks for opening the issue! We had a similar discussion in #2067 .

@drdanz
Copy link
Member

drdanz commented Nov 25, 2020

That's the same bug, I'm closing this in favour of #2067

@drdanz drdanz closed this as completed Nov 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants