Summary
Compiler MinGW
OS Windows 7 x64
glViewport()
function gives Undefined Reference
error
I have tried
- adding
-lGL
resultedcannot find -lGL
<-- How do I locate OpenGL dll files ? - checked
-Lpath -lglew32 -lglfw3
as if not last linker argument
I 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
- OpenGL
- bins
- glew32.dll
- glfw3.dll
- includes
- GL
- glew.h
- glewx.h
- wglew.h
- GLFW
- glfw3.h
- glfw3native.h
- GL
- libs
- glfw3.lib
- bins
Long Story
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.
Code
#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.
-Wl,--verbose
to the command options should give more information then. That passes--verbose
to the linker – KriesD:\OpenGL\OpenGLTutorial/sample.cpp:21: undefined reference to glClearColor@16'
-D:\OpenGL\OpenGLTutorial/sample.cpp:22: undefined reference to glClear@4'
– Phylis