c++ - Assimp 样本给出错误

标签 c++ opengl assimp

我刚拿到最后一个assimp SDK,做了一个项目,我正确地链接了它(链接没有错误)但是我似乎在Sample项目上遇到了一些麻烦。更具体地说,是 SimpleOpenGL。 我将 C++ 与 OpenGL 和 visual studio 10 结合使用。

struct aiVector3D scene_min, scene_max, scene_center;

上面的行会产生以下错误。

1>main.cpp(25): error C2371: 'aiVector3D' : redefinition; different basic types
1>d:\libraries\assimp--3.0.1270-sdk\include\assimp\vector3.h(124) : see declaration of 'aiVector3D'
1>main.cpp(25): error C2079: 'scene_min' uses undefined struct 'aiVector3D'
1>main.cpp(25): error C2079: 'scene_max' uses undefined struct 'aiVector3D'
1>main.cpp(25): error C2079: 'scene_center' uses undefined struct 'aiVector3D'

还有更多的错误,但如果在我解决这个错误后仍然出现,我会发布它们。

根据评论进行编辑

看起来很有效!谢谢。但是您能解释一下为什么 struct 这个词不会影响 C 语言的程序吗?

最佳答案

你必须删除 struct 这个词根据您的定义,因为 aiVector3D声明不同 in the header file .

在链接的头文件中,您会看到 #ifdef __cplusplus 行预处理器使用它进行条件编译。这意味着一切直到下一个 #else如果使用 C++ 编译器,将被编译到目标文件中。这段代码告诉我们 aiVector3D 是 aiVector3t<float> 的类型定义(= 其他名称) .

如果你使用普通的 C 编译器,aiVector3D 的声明是

struct aiVector3D {
    float x,y,z;
}

这符合您的定义。

关于c++ - Assimp 样本给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16066881/

相关文章:

c++ - 使用 OpenGL 在 Qt 中显示来自 DirectShow 的原始图像数据

opengl - 奇怪的 OpenGL 像素缺陷

c++ - Assimp 不在 OpenGL 中的 MD5 模型 Bob 的节点中加载骨骼名称

c - opengl模型纹理坐标问题

iphone - 在 3D 场景中定位对象,然后找出用户点击的内容

c++ - Qt:QFuture/QtConcurrent超时函数调用

OpenGL 定向光着色器

c++ - obj + mlt 3d 模型呈现错误的颜色

c++ - Controller 中用于模型和 View 之间接口(interface)的通用编程

c++ - 与 sprintf 斗争......愚蠢的事情?