Compiler MinGW
OS Windows 7 x64
glViewport()
function gives Undefined Reference
error
I have tried
-lGL
resulted cannot find -lGL
<-- How do I locate OpenGL dll files ?-Lpath -lglew32 -lglfw3
as if not last linker argumentI may have miscompiled GLEW and/or miscopied GLEW libs as I am not sure if I need libglew32.a and/or libglew32.dll.a files.
I have a folder structure like that
Hello experienced programmers. Your humble questioner returns. Today me and my friend decided to start/learn OpenGL. As we follow this tutorial, we have stuck at glViewport
as it gives Undefined reference
error. We are working on NetBeans 8.0 C/C++ version. I have double checked the Makefile
as some sites mentioned -Lpath -lglew32 -lglfw3
had to be last parameter when compiling. I have tried to ad -lGL
as linker option, but sadly it won't work.
#include <cstdlib>
//GLEW
#include "GL/glew.h"
//GLFW
#include "GLFW/glfw3.h"
using namespace std;
/*
*
*/
int main(int argc, char** argv) {
glewExperimental = GL_TRUE;
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL , NULL);
glfwMakeContextCurrent(window);
glViewport(0, 0, 800, 600);
return 0;
}
As a side note this is my first time using libraries other than standards. Well Summary looking much longer than Long Story..
Edit: I do not think this is a duplicate question as I'm asking linking of a specific library, not how can I link something in C++. This is like saying all coding questions are same as all of them involves writing code. Checked the said topic and cannot find any direction about linking opengl32 library.
In Windows the OpenGL API interface library is called opengl32
not GL
, hence you must link with
-lopengl32
(note that it's always …32, even on 64 bit systems).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With