需要使用g++编译vcglib代码的帮助
Need help compiling vcglib code with g++
我正在学习如何使用库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 ‘<’ 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)
我对模板了解不多,所以我不知道问题出在哪里,也不知道该如何解决。这是从我上面链接的vcglib网站上直接下载的代码,我没有修改任何代码,所以我很惊讶它没有编译。
看起来他们给出的大多数例子都是针对windows电脑和视觉工作室的。我正在运行arch-linux,并使用g++编译它。问题可能是两个编译器之间的差异吗?
我真的很失落,任何帮助都将不胜感激。
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> > {};
相关文章:
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 代码在main()中运行,但在函数中出现错误
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 编译包含字符串的代码时遇到问题
- 我在c++代码中生成了一个运行时#3异常
- 如何在linux终端中同时编译和运行c++代码
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 在Linux for Windows上编译C++代码时出错
- 我的字符计数代码计算错误.为什么
- 孤立代码块在结构中引发异常
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 此代码是否违反一个定义规则
- 为什么我的代码在输出中增加了93天
- 我的简单if-else语句是如何无法访问的代码
- 使用动态分配的数组会导致代码分析发出虚假的C6386缓冲区溢出警告
- 为什么在这个代码结束循环中没有得到结束
- 需要使用g++编译vcglib代码的帮助
- VCGlib中的示例代码使Visual Studio 2013崩溃