Undefined references OpenGL on Ubuntu 14.04

I am trying to compile an OpenGL program in Ubuntu.
This program opens a blank window.

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <cstdio>
#include <iostream>

int main(int argc,char* argv[])
{
	glfwInit();
	glfwWindowHint(GLFW_VERSION_MAJOR,3);
	glfwWindowHint(GLFW_VERSION_MINOR,2);
	glfwWindowHint(GLFW_OPENGL_PROFILE,GLFW_OPENGL_CORE_PROFILE);
	glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT,GL_TRUE);
	
	glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);
	
	GLFWwindow* window=glfwCreateWindow(800,600,"OpenGL",nullptr,nullptr);
	
	glfwMakeContextCurrent(window);
	
	while(!glfwWindowShouldClose(window))
	{
		glfwSwapBuffers(window);
		glfwPollEvents();
	}
	
	glfwTerminate();
}


This is my compile/link log when I use g++ -o helloGL helloGL.cpp -lGLEW -lglfw3 -lGL -lX11 -std=c++11:


/usr/bin/ld: //usr/local/lib/libglfw3.a(x11_init.c.o): undefined reference to symbol 'XF86VidModeQueryExtension'
//usr/lib/i386-linux-gnu/libXxf86vm.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status


How do I fix this?

Thanks in advance.

Add -lXxf86vm?
Doesn't work:
/usr/bin/ld: //usr/local/lib/libglfw3.a(glx_context.c.o): undefined reference to symbol 'pthread_key_delete@@GLIBC_2.0'
//lib/i386-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Either -lpthread or -lthread.
I think you meant -pthread...? Which seems to be the preferred method to link against the pthread library.
Whatever works.
-lpthread, however order of libraries added is important.
Registered users can post here. Sign in or register to post.