ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Compile two classes with same name

asked 2012-12-11 15:44:41 -0500

mobot3 gravatar image

updated 2014-01-28 17:14:32 -0500

ngrennan gravatar image

I'm trying to get rgbdslam to work with fuerte, which seems difficult from what I have culled from other posts. I am now encountering an error with compiling two classes that have the same name. I tried removing one but they both are required by other files. This is an excerpt of the error message I get after trying rosmake rgbdslam

  [ 41%] Building CXX object CMakeFiles/rgbdslam.dir/src/main.o
  In file included from /opt/ros/fuerte/include/g2o/core/hyper_dijkstra.h:34:0,
                   from /home/linus/Fuerte/sandbox/rgbdslam_freiburg/rgbdslam/src/graph_manager.h:53,
                   from /home/linus/Fuerte/sandbox/rgbdslam_freiburg/rgbdslam/src/openni_listener.h:30,
                   from /home/linus/Fuerte/sandbox/rgbdslam_freiburg/rgbdslam/src/main.cpp:17:
  /opt/ros/fuerte/include/g2o/core/hyper_graph.h:59:22: error: redefinition of ‘class g2o::HyperGraph’
  /home/linus/Fuerte/sandbox/g2o/include/g2o/core/hyper_graph.h:47:9: error: previous definition of ‘class g2o::HyperGraph’
  make[3]: *** [CMakeFiles/rgbdslam.dir/src/main.o] Error 1
  make[3]: Leaving directory `/home/linus/Fuerte/sandbox/rgbdslam_freiburg/rgbdslam/build'
  make[2]: *** [CMakeFiles/rgbdslam.dir/all] Error 2
  make[2]: Leaving directory `/home/linus/Fuerte/sandbox/rgbdslam_freiburg/rgbdslam/build'
  make[1]: *** [all] Error 2
  make[1]: Leaving directory `/home/linus/Fuerte/sandbox/rgbdslam_freiburg/rgbdslam/build'
-------------------------------------------------------------------------------}
[ rosmake ] Output from build of package rgbdslam written to:
[ rosmake ]    /home/linus/.ros/rosmake/rosmake_output-20121211-223719/rgbdslam/build_output.log
[rosmake-2] Finished <<< rgbdslam [FAIL] [ 9.35 seconds ]                               
[ rosmake ] Halting due to failure in package rgbdslam. 
[ rosmake ] Waiting for other threads to complete.
[ rosmake ] Results:                                                                    
[ rosmake ] Built 32 packages with 1 failures.

It appears that I am close, or at least 41% of the way, to getting the code to compile but I am unsure how to solve the 2-classes-1-name issue with my minimal C++ exposure. In addition, below is a portion of the hyper_graph.h file. The class declaration is near the end

#ifndef G2O_AIS_HYPER_GRAPH_HH
#define G2O_AIS_HYPER_GRAPH_HH
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <vector>
#include <limits>
#include <cstddef>

#ifdef _MSC_VER
#include <unordered_map>
#else
#include <tr1/unordered_map>
#endif

#include "g2o_core_api.h"

/** @addtogroup graph */
//@{
namespace g2o {
  class G2O_CORE_API HyperGraph {
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2012-12-12 03:03:10 -0500

thebyohazard gravatar image

Perhaps you mean for the class G2O_CORE_API to inherit from the class HyperGraph? I'm definitely no expert in C++, but I've never seen that syntax before. If you do mean to extend HyperGraph, use a colon to specify classes from which to inherit. Like this:

class G2O_Core_API : HyperGraph {

If you didn't mean to inherit, I'd sure like to know what the syntax is and how to use it!

edit flag offensive delete link more
0

answered 2012-12-13 14:31:34 -0500

mobot3 gravatar image

While this isn't exactly a solution, it does provide a different error, which perhaps someone can find easier to troubleshoot. I found that the conflict was between two classes with the same name, one in ~/Fuerte/sandbox/g2o/include/g2o/core/, and the other was in /opt/ros/fuerte/include/g2o/core/. I'm not sure how there came to be two folders so similar in different locations, but I did install g2o more than once, so either that or the ROS file structure could be the issue. I renamed the folder in /opt/ros/fuerte/include/g2o to g3o (or something else) and got multiple errors similar to graph_manager.cpp:(.text._ZN3g2o11BlockSolverINS_17BlockSolverTraitsILi6ELi3EEEE5solveEv[g2o::BlockSolver<g2o::BlockSolverTraits<6, 3> >::solve()]+0x1176): undefined reference to g2o::globalStats It seems that this issue could be related to the position of #ifndef and #endif in the batch_stats.h file, which is where globalStats is defined, but I'm still figuring out how to solve that.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-12-11 15:44:41 -0500

Seen: 366 times

Last updated: Dec 13 '12