1

ライブラリ vcglib (http://vcg.sourceforge.net/index.php/Main_Page) の使用方法を学ぼうとしていますが、コンパイルするのに最も苦労しています。今、私は trimesh_definition.cpp をコンパイルしようとしています。これは、すべてを起動して実行する方法を示すはずの vcglib に付属する基本的な例です。

コンパイルしようとしているコードは次のとおりです。

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 }

次のコマンドでコードをコンパイルしています。

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

次のエラーが表示されます。

trimesh_definition.cpp:13:40: error: expected template-name before ‘&lt;’ token
trimesh_definition.cpp:13:40: error: expected ‘{’ before ‘&lt;’ token
trimesh_definition.cpp:13:40: error: expected unqualified-id before ‘&lt;’ token
trimesh_definition.cpp:14:36: error: expected template-name before ‘&lt;’ token
trimesh_definition.cpp:14:36: error: expected ‘{’ before ‘&lt;’ token
trimesh_definition.cpp:14:36: error: expected unqualified-id before ‘&lt;’ 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)

テンプレートについてよく知らないので、何が問題なのか、どのように修正すればよいのかわかりません。これは、上記でリンクした vcglib Web サイトから直接ダウンロードしたコードであり、何も変更していないため、コンパイルされないことに驚いています。

彼らが提供する例のほとんどは、Windowsコンピューターとビジュアルスタジオ向けのようです。Arch Linux を実行しており、これを g++ でコンパイルしています。問題は 2 つのコンパイラの違いでしょうか?

私は本当に迷っています。どんな助けでも大歓迎です。

4

1 に答える 1

1

VertexSimp2(および 1 と 3 も) 古いバージョンの vcg で使用されるクラスです。Lib を検索すると、 の定義が見つかりませんclass VertexSimp2

これはまさにコンパイラが言うvcg::VertexSimp2ことであり、型であることが期待されていますが、そうではありません。

チュートリアルでは、実際のソリューションを提供しています:

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> > {};
于 2012-03-16T18:46:58.753 に答える