CroCo
CroCo

Reputation: 5741

why do I have to link against opengl32.lib

I'm using modern openGL 3.3. The libraries are glfw-3.1.1 for the window and glew-1.12.0 for the OpenGL content. I've built all libs with visual studio 2012. Basically everything is running however, once I use this line glDrawArrays(GL_TRIANGLES, 0, 3);, it throws out this error

main.obj : error LNK2019: unresolved external symbol __imp__glDrawArrays@12 referenced in function _main
test.exe : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\cl.EXE"' : return code '0x2'

Once I link against opengl32.lib, it worked. My question is when I use OpenGL in Windows, do I have always to link against the preceding lib.

Upvotes: 1

Views: 1161

Answers (2)

Ray Donnelly
Ray Donnelly

Reputation: 4086

I think the confusion here comes from wanting to use OpenGL 3.3, but in doing so linking to opengl32.lib.

The 32 here isn't a version number, it is from WIN32, the name of the Windows C / C++ API.

Upvotes: 0

datenwolf
datenwolf

Reputation: 162164

glDrawArrays is an old function. It's been part ever since OpenGL-1.1 introduced vertex arrays so it's been there since the beginning, 20 years ago. As such it's not part of anything that's exposed through the extension mechanism, but through the good old opengl32.dll – which BTW you always have to link against if you want to use OpenGL. Some OpenGL loaders will do it for you behind the scenes, but if you're using OpenGL in Windows, you always link against opengl32.dll

Upvotes: 2

Related Questions