Reputation: 511
I am trying to build an OpenGL app in c++. I use the glew and glfw libraries. Now I wanted to create some textures, but now it says:
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
Everything worked so far(glGenVertexArrays(), glDrawArrays(), etc.), only the texture functions(glGenTextures(), glBindTexture(), etc.) don't work.
The Linker is set up like this: glew32.lib;glfw3.lib;assimp.lib;devil.lib;magickdb.lib;magickrl.lib;%(AdditionalDependencies)
VC include dir:
C:\Users\Dynamitos5\Documents\cuda\OpenGLTest\external\include;$(IncludePath)
VC lib dir:
C:\Users\Dynamitos5\Documents\cuda\OpenGLTest\external\lib;$(LibraryPath)
Upvotes: 2
Views: 5498
Reputation: 707
A few things going on here... OpenGL comes with Windows but only up to OpenGL 1.1 with opengl32.lib. Thus, the need of an extension library, such as glew, for all subsequent OpenGL versions. Now, freeglut includes opengl32.lib but glew does not, so you must include opengl32.lib yourself if you are using glew. Under Visual Studio, right click on your project (in bold), then add openg32.lib in Properties/Linker/Input. No need to add any additional directories in C/C++/General or Linker/General in Properties - opengl32.lib is coming with Windows, Visual Studio knows where to find it but still needs to be told to link against it! Lastly, copy the corresponding dynamic libraries, such as freeglut.dll or glew32.dll, in the Visual Studio Debug directory where your executable file is.
Upvotes: 1
Reputation: 22165
All functions up to OpenGL 1.1 are implemented directly in the opengl32.lib
library. All other functions are available through extension and have to be loaded manually (or by using a library like glew).
In your case, you are missing to link agains the opengl32.lib
.
Upvotes: 8