Question

I managed to install vtk on my ubuntu. I'm using code::Blocks as compiler, working in c++. I also compiled and ran some of the examples given in the vtk examples web page. But at some examples, for example when vtkChart.h is involved, my compiler gives errors which refer to the content of the file.

These header files are generated automatically and should contain no errors. You can check the image below. What may be wrong? Is it caused by the compiler?

Thank your all.

enter image description here

For those who can't see the picture, the code is given below:

#ifndef __vtkChart_h
#define __vtkChart_h

#include "vtkContextItem.h"

class vtkTransform2D;
class vtkContext2D;
class vtkContextScene;
class vtkPlot;
class vtkAxis;
class vtkTextProperty;

class vtkInteractorStyle;
class vtkAnnotationLink;
class vtkTable;

class VTK_CHARTS_EXPORT vtkChart : public vtkContextItem
{
public:
  vtkTypeMacro(vtkChart, vtkContextItem);
  virtual void PrintSelf(ostream &os, vtkIndent indent);

just for the code segment shown, errors below show up.

../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|38|error: expected class-name before ‘{’ token|

../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|40|error: ‘vtkContextItem’ does not name a type|

../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|40|error: ‘vtkContextItem’ has not been declared|

../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|40|error: invalid static_cast from type ‘vtkObjectBase*’ to type ‘vtkChart*’|

../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h||In member function ‘virtual vtkObjectBase* vtkChart::NewInstanceInternal() const’:|

../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|40|error: ‘New’ is not a member of ‘vtkChart’|

and goes on..

Was it helpful?

Solution

First, Code::Blocks is not a compiler, it's an IDE that uses GCC or MSVC as a compiler. So, this should be more generic to GCC itself (since you appear to be using Ubuntu).

Your problem looks like a configuration error. ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|40|error: ‘vtkContextItem’ does not name a type| is the kind of error that occurs when the compiler couldn't find vtkContextItem.h. Were there any errors above that say something like "vtkContextItem.h not found"?

Try using CMake to configure your project if you aren't already doing so. Generally CMake will do a better job of setting up the configuration than you could by yourself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top