Question

I'm trying to learn how to use the library vcglib (http://vcg.sourceforge.net/index.php/Main_Page) but I'm having the hardest time getting anything to compile. Right now I'm trying to compile trimesh_definition.cpp which is just a basic example that came with vcglib that is supposed to show how to get everything up and running.

Here is the code I'm trying to comiple:

1  #include <vector>
2 
3  #include <vcg/simplex/vertex/base.h>
4  #include <vcg/simplex/vertex/component.h>
5  #include <vcg/simplex/face/base.h>
6  #include <vcg/simplex/face/component.h>
7 
8  #include <vcg/complex/complex.h>
9 
10 class MyEdge;
11 class MyFace;
12 
13 class MyVertex: public vcg::VertexSimp2<MyVertex,MyEdge,MyFace, vcg::vert::Coord3d, vcg::vert::Normal3f>{};
14 class MyFace: public vcg::FaceSimp2<MyVertex,MyEdge,MyFace, vcg::face::VertexRef>{};
15 
16 class MyMesh: public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> > {};
17 
18 int main()
19 {
20    MyMesh m;
21    return 0;
22 }

I'm comipling the code with the following command:

g++ -I ../../../vcglib trimesh_definition.cpp -o trimesh_def

I get the following errors:

trimesh_definition.cpp:13:40: error: expected template-name before ‘<’ token
trimesh_definition.cpp:13:40: error: expected ‘{’ before ‘<’ token
trimesh_definition.cpp:13:40: error: expected unqualified-id before ‘<’ token
trimesh_definition.cpp:14:36: error: expected template-name before ‘<’ token
trimesh_definition.cpp:14:36: error: expected ‘{’ before ‘<’ token
trimesh_definition.cpp:14:36: error: expected unqualified-id before ‘<’ token
In file included from trimesh_definition.cpp:8:0:
/home/martin/Programming/Graphics/libraries/vcglib/vcg/complex/complex.h: In instantiation of ‘vcg::tri::TriMesh<std::vector<MyVertex>, std::vector<MyFace> >’:
trimesh_definition.cpp:16:86:   instantiated from here
(... followed by many more screenfulls of template info)

I don't really know much about templates so I have no idea what the problem is or how I should go about fixing it. This is code downloaded straight from the vcglib website which I linked to above and I haven't modified any of it so I'm suprised that it doesn't compile.

It looks like most of their examples that they give are for windows computers and visual studios. I'm running arch linux and I'm compiling this with g++. Could the problem be a difference between the two compilers?

I'm really lost, any help would be much appreciated.

Was it helpful?

Solution

VertexSimp2 (and 1 and 3 too) is a class used in old versions of vcg. Search your Lib, you won't find a definition of the class VertexSimp2.

This is exactly what the compiler says, vcg::VertexSimp2 is expected to be a type, but it isn't.

The Tutorial offers you the actual solution:

class MyUsedTypes: public vcg::UsedTypes< vcg::Use<MyVertex>::AsVertexType>,
                                          vcg::Use<MyFace>::AsFaceType>  


class MyVertex : public vcg::Vertex<MyUsedTypes, vcg::vertex::Coord3d, vcg::vertex::Normal3f> {};
class MyFace : public vcg::Face<MyUsedTypes, vcg::face::VertexRef> {};
class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> > {};
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top