How to build GLFW3 project on Linux?

Jostein picture Jostein · Jul 10, 2013 · Viewed 16.3k times · Source

I've compiled glfw3 and the included examples using cmake and make without problems. Onto writing my first project. Being new to opengl and glfw, and unexperienced with C and CMake, i'm struggling to understand the example build files, or even which libraries to link and/or compiler parameters to use in my project.

Let's say i have just one folder with one file, boing.c for now. How would i compile it?

Simply running gcc -lglfw3 -lm -lGL -lGLU boing.c gives a wall of undefined references, starting with sin and atan2, followed by various gl and glfw stuff. What am i missing?

How would i go about writing a makefile? Is there a cmake template or sample, that i just didn't understand how to use or adapt? Does anyone know about an open source project (or better, a small example or template) using glfw3 -- so i can look around?

I'm guessing cmake would be best, when i want to go multi-platform at some point. But how do i just get the **** thing to compile without too much hassle, so i can get started on some tutorials..?

I'm a moderate noob using 32bit Ubuntu raring. Just using Vim for now.

Answer

Cluster picture Cluster · Jul 27, 2013

You need to include library like this

-lGL -lGLU -lglfw3 -lX11 -lXxf86vm -lXrandr -lpthread -lXi

#Ref : http://www.blogosfera.co.uk/2013/07/how-to-build-install-glfw-3-and-use-it-in-a-linux-project/

Sorry i'm not good in english