繁体   English   中英

OpenGL链接问题

[英]OpenGL Linking problems

我正在尝试用c ++构建OpenGL应用程序。 我使用glew和glfw库。 现在我想创建一些纹理,但是现在它说:

1>model.obj : error LNK2019: unresolved external symbol __imp_glBindTexture referenced in function "public: void __cdecl Texture::Bind(unsigned int)" (?Bind@Texture@@QEAAXI@Z)
1>model.obj : error LNK2019: unresolved external symbol __imp_glGenTextures referenced in function "public: bool __cdecl Texture::Load(void)" (?Load@Texture@@QEAA_NXZ)
1>model.obj : error LNK2019: unresolved external symbol __imp_glTexImage2D referenced in function "public: bool __cdecl Texture::Load(void)" (?Load@Texture@@QEAA_NXZ)
1>model.obj : error LNK2019: unresolved external symbol __imp_glTexParameterf referenced in function "public: bool __cdecl Texture::Load(void)" (?Load@Texture@@QEAA_NXZ)
1>C:\Users\Dynamitos5\Documents\cuda\OpenGLTest\external\lib\magickdb.lib : warning LNK4272: library machine type 'X86' conflicts with target machine type 'x64'
1>C:\Users\Dynamitos5\Documents\cuda\OpenGLTest\external\lib\magickrl.lib : warning LNK4272: library machine type 'X86' conflicts with target machine type 'x64'
1>C:\Users\Dynamitos5\Documents\cuda\OpenGLTest\x64\Debug\OpenGLTest3.exe : fatal error LNK1120: 16 unresolved externals

到目前为止,一切正常(glGenVertexArrays(),glDrawArrays()等),仅纹理函数(glGenTextures(),glBindTexture()等)无效。 链接器的设置如下: glew32.lib;glfw3.lib;assimp.lib;devil.lib;magickdb.lib;magickrl.lib;%(AdditionalDependencies)

VC include目录: C:\\Users\\Dynamitos5\\Documents\\cuda\\OpenGLTest\\external\\include;$(IncludePath) VC lib目录: C:\\Users\\Dynamitos5\\Documents\\cuda\\OpenGLTest\\external\\lib;$(LibraryPath)

OpenGL 1.1之前的所有功能都直接在opengl32.lib库中实现。 所有其他功能都可以通过扩展程序获得,并且必须手动加载(或通过使用glew之类的库)加载。

就您而言,您缺少再次链接opengl32.lib

这里发生了一些事情... OpenGL随Windows一起提供,但直到opengl32.lib才支持OpenGL 1.1。 因此,所有后续的OpenGL版本都需要扩展库(例如glew)。 现在,freeglut包含opengl32.lib,但glew不包含,因此,如果您使用glew,则必须自己包含opengl32.lib。 在Visual Studio下,右键单击您的项目(粗体),然后在Properties / Linker / Input中添加openg32.lib。 无需在C / C ++ / General或Properties中的Linker / General中添加任何其他目录-Windows附带了opengl32.lib,Visual Studio知道在哪里可以找到它,但仍然需要告诉它进行链接! 最后,将相应的动态库(例如freeglut.dll或glew32.dll)复制到可执行文件所在的Visual Studio调试目录中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM