无法解析的外部符号(OpenGL和C ++) [英] Unresolved external symbol (OpenGL and c++)

查看:655
本文介绍了无法解析的外部符号(OpenGL和C ++)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我在写一个小项目,没什么复杂的,它只有几个类. 顾名思义,它使用OpenGL.目前,还没有真正的"主要功能. 无论在哪里使用gl *函数调用,我都将glew.h包含在内,并将其添加到链接器输入glew32.lib中.

OK, so I'm writing a little project, nothing complex, it just has several classes. As the title implies, it uses OpenGL. At the moment, there's no "real" main function. I have included glew.h wherever I've used gl* function calls, and added to the linker input glew32.lib.

但是,它给了我这个:

错误2错误LNK2019:未解析的外部符号 函数"public:void __thiscall Texture2D :: Bind(unsigned int)"中引用的_ imp _glBindTexture @ 8 (?Bind @ Texture2D @@ QAEXI @ Z)Texture.obj Licenta

Error 2 error LNK2019: unresolved external symbol _imp_glBindTexture@8 referenced in function "public: void __thiscall Texture2D::Bind(unsigned int)" (?Bind@Texture2D@@QAEXI@Z) Texture.obj Licenta

...以及与OpenGL纹理函数有关的许多其他未解决的外部符号错误.但这并没有抱怨:

... and a host of other unresolved external symbol errors regarding OpenGL texture functions. But it doesn't complain about this:

glBindVertexArray(m_VAO);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_Buffers[INDEX_BUFFER]);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(Indices[0]) * Indices.size(), &Indices[0], GL_STATIC_DRAW);

或者这个:

glDrawElementsBaseVertex(GL_TRIANGLES, 
                             m_Entries[i].NumIndices, 
                             GL_UNSIGNED_INT, 
                             (void*)(sizeof(unsigned int) * m_Entries[i].BaseIndex), 
                             m_Entries[i].BaseVertex);

那是怎么回事?如果一个gl *函数调用失败,是否所有链接都将失败?

So, what's the deal? If one gl* function call failed linking, wouldn't ALL have to fail?

推荐答案

glBindTexture是OpenGL的核心"功能.该函数位于opengl32.dll中,因此只需将opengl32.lib添加到链接器输入中即可.

glBindTexture is a "core" OpenGL feature. This function resides in opengl32.dll, so just add the opengl32.lib to your linker input.

glDrawElementsBaseVertex和glBindVertexArray是扩展,并且GLEW将它们定义为函数指针(在运行时完成了动态后期绑定),因此没有未解决的符号"错误.

glDrawElementsBaseVertex and glBindVertexArray are extensions and GLEW defines these as function pointers (with dynamic late binding done in runtime), thus no "unresolved symbol" errors.

这篇关于无法解析的外部符号(OpenGL和C ++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆