2016-01-01 173 views
1

我想在C++中构建一个OpenGL应用程序。我使用glew和glfw库。现在,我想创造一些纹理,但现在它说:OpenGL链接问题

1>model.obj : error LNK2019: unresolved external symbol __imp_glBindTexture referenced in function "public: void __cdecl Texture::Bind(unsigned int)" ([email protected]@@[email protected]) 
1>model.obj : error LNK2019: unresolved external symbol __imp_glGenTextures referenced in function "public: bool __cdecl Texture::Load(void)" ([email protected]@@QEAA_NXZ) 
1>model.obj : error LNK2019: unresolved external symbol __imp_glTexImage2D referenced in function "public: bool __cdecl Texture::Load(void)" ([email protected]@@QEAA_NXZ) 
1>model.obj : error LNK2019: unresolved external symbol __imp_glTexParameterf referenced in function "public: bool __cdecl Texture::Load(void)" ([email protected]@@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(),(4,8)等),只纹理函数(glGenTextures(),glBindTexture()等)不起作用。 接头是建立这样的:glew32.lib;glfw3.lib;assimp.lib;devil.lib;magickdb.lib;magickrl.lib;%(AdditionalDependencies)

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

+0

你是否缺少opengl32.lib? – BDL

+0

@BDL我认为opengl32.lib只适用于已弃用的OpenGL1.1内容。我的错误理解/ _ \。我会接受它,如果你把它作为回答 – Dynamitos

回答

3

所有功能到OpenGL的1.1直接在opengl32.lib库中实现。所有其他功能都可以通过扩展使用,并且必须手动加载(或使用像glew这样的库)。

对您而言,您错过了重新链接opengl32.lib

0

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

+0

GLUT/freeglut不是扩展装载机。他们管理窗口,上下文和事件。 – derhass