编译项目时的错误https://svn.openslam.org/data/svn/hog-man

时间:2015-09-06 10:31:56

标签: c++ linux compilation

我正在使用安装指令

在linux GNU C ++下编译hog-man
@verbatim
$ svn co http://www.openslam.org/data/svn/hog-man
 $ cd hog-man/trunk/
 $ bash               # if not already running
 $ source setlibpath
 $ ./configure
 $ make
@endverbatim 

安装了Csparse。

运行最后一步时出错:

    from hogman2d.cpp:18:
    graph_optimizer_chol.hpp: In member function ‘virtual typename   
    PG::Edge* AISNavigation::CholOptimizer<PG>::addEdge(typename 
    PG::Vertex*, typename PG::Vertex*, const typename 
    PG::TransformationType&, const typename PG::InformationType&)’:
    graph_optimizer_chol.hpp:284:25: error: expected primary-    expression before ‘&&’ token
   if (_guessOnEdges && to->edges().size()==1 && ! to->fixed()){
                     ^
  Failed command was:
   g++ -fPIC -DLINUX -I/home/sophie/hog-man/trunk          
  -D_MY_CAST_=reinterpret_cast -I/home/sophie/hog-man/trunk/aislib -fPIC
  -O3 -Wall -frtti -mmmx -msse3 -c hogman2d.cpp -o hogman2d.o
   in directory  /home/sophie/hog-man/trunk/aislib/graph_optimizer_hogman
  ../../build_tools/Makefile.generic-shared-object:55: recipe for target     'hogman2d.o' failed
 make[2]: *** [hogman2d.o] Error 1
    Compilation in graph_optimizer_hogman failed.
 ../build_tools/Makefile.subdirs:10: recipe for target 'all' failed
make[1]: *** [all] Error 1
Compilation in aislib failed.
 build_tools/Makefile.subdirs:10: recipe for target 'all' failed
 make: *** [all] Error 1

表达式_guessOnEdges有什么问题?

它在GraphOptimizerChol.h中以下列方式声明:

  protected:
  using typename GraphOptimizer<PG>::_guessOnEdges;

在GraphOptimizer.h中,它按以下方式定义:

  public:
  GraphOptimizer();
  virtual ~GraphOptimizer();

  virtual bool initialize(int rootNode=-1)=0;
  virtual int optimize(int iterations, bool online=false)=0;

  double chi2() const;
  static double chi2(const typename PG::Edge* e);
  static void absChi(double& rotationalError, double&      translationalError,       typename PG::Edge* e_);
  void chiStat(ChiStatMap& emap);
  void sqError(double& are, double& ate, double& mte, double& mre,        const    typename PG::EdgeSet* eset=0) const;

  virtual const bool& verbose() const { return _verbose; }
  virtual bool& verbose() { return _verbose; }
  virtual const bool& visualizeToStdout() const { return     _visualizeToStdout; }
  virtual bool& visualizeToStdout() { return _visualizeToStdout; }
  virtual const bool& guessOnEdges() const { return _guessOnEdges;}
  virtual bool& guessOnEdges() { return _guessOnEdges;}

  virtual void backup();
  virtual void restore();

protected:
  virtual void backupSubset(typename PG::VertexSet& vset);
  virtual void backupSubset(Graph::VertexSet& vset);
  virtual void restoreSubset(typename PG::VertexSet& vset);
  virtual void restoreSubset(Graph::VertexSet& vset);

  bool _verbose;
  bool _visualizeToStdout;
  bool _guessOnEdges;

  using PG::_vertices;
  using PG::_edges;
   };

在GraphOptimizer.hpp中:

 template <typename PG>
 GraphOptimizer<PG>::GraphOptimizer() :
  PG(),
 _verbose(false), _visualizeToStdout(false), _guessOnEdges(false)
   {
   }

并在GraphOptimizerChol.cpp中:

    56: bool initFromObservations = _guessOnEdges; 

所以它被定义了,但它初始化的地方是,这个方法执行时它没有被初始化的问题?

     if (_guessOnEdges && to->edges().size()==1 && ! to->fixed()){
      to->transformation=from->transformation*mean;
        }
  return e;
}

1 个答案:

答案 0 :(得分:1)

using typename GraphOptimizer<PG>::_guessOnEdges;

当您使用typename声明内容时,表示它是类型

您不能在表达式中使用类型。

您不能在属性上使用using

因此,解决方案有两个方面:

  • 删除using声明
  • 在表达式中使用this->_guessOnEdges

这会给你:

if (this->_guessOnEdges && to->edges().size()==1 && ! to->fixed()){
    to->transformation=from->transformation*mean;
}

这里需要this告诉编译器_guessOnEdges是一个依赖符号,并且在模板实例化之前无法解析。