I have a Visual Studio c++ project in which I am using GLFW.
I have seen tutorials using glad, as well as GLEW alongside GLFW.
However, I am getting errors, which I don’t know how to solve, or why I am getting them. I am following tutorials, including the ones from GLFW website.
When I use this code…
// If using GLEW version 1.13 or earlier
//glewExperimental = true;
GLenum err = glewInit();
if (err != GLEW_OK) {
// Problem: glewInit failed, something is seriously wrong.
cout << "glewInit failed: " << glewGetErrorString(err) << endl;
exit(1);
}
I get these errors…
Error
LNK2019
unresolved external symbol __imp_glewInit referenced in function private: bool __cdecl mainWindow::init(void) (?init@mainWindow@@AEAA_NXZ)
Error
LNK2019
unresolved external symbol __imp_glewGetErrorString referenced in function private: bool __cdecl mainWindow::init(void) (?init@mainWindow@@AEAA_NXZ)
Error
LNK1120
2 unresolved externals
I tried the solution [unresolved external symbol __imp__glewInit VS __imp__glewInit@0] on stackoverflow, but it does not solve the problem.
I’m wondering if the problem has anything to do with the architecture. I can’t find 64 bit GLEW.
I also have a problem using the glad library.
When I include glad #include <glad/glad.h>
I get an error telling me to remove the include because it is already included.
So when I try this… gladLoadGL([glfwGetProcAddress);
gladLoadGL is undefined, suggesting that glad is not included.
Any suggestion on how I can resolve these issues would be much appreciated. Thanks.
GLEW and GLAD do the same thing. There is no reason to have a file that uses both. And the only reason to have a project that uses both is if you’re including some library that uses one while you’re using the other, but even then, you have to separate them out so that no single file tries to include both (directly or indirectly).
If this is all your code, then you need to pick which one you want to use.
What happened, is I was trying GLEW, and that failed, so I tried GLAD.
In any case, I wanted to see if I could get GLAD to work.
If the problem with GLAD cannot be resolved, I suppose I don’t need to bother with it.
Still, it would be helpful to know why it isn’t working.
Thanks.
I thought I explained that: you cannot use both GLAD and GLEW in the same file. They both try to include the OpenGL headers, and they both expect to be the only code doing that. So either of them will error in the presence of the other. Get rid of #include <GL/glew.h> (and all other vestiges of GLEW), and GLAD will work.