View Full Version : OpenGL Linking
May 31st, 2009, 09:13 PM
Hello I am new to Ubuntu and I wanted to know how to install and link to the OpenGL and GLUT libraries in g++. I am used to Mac where I just do 'g++ -framework OpenGL -framework GLUT' but I understand that I have to compile the libraries and than link to them as a library. Could someone explain to me how to do this?
June 1st, 2009, 11:29 PM
You don't need to compile the glut and GL libraries yourself, you just need to install the development packages.
sudo apt-get install freeglut3-dev mesa-common-dev
This will install the GLUT and GL headers for you.
You can then compile with:
g++ your_file.cc your_file_2.cc $(pkg-config --cflags --libs gl) -lglut -o test_program
pkg-config is a program that will spit out the necessary include (-I) and linking (-l) compiler directives for the specified package, in this case GL. -lglut tells the compiler to link against the GLUT shared library (since there is no pkg-config entry for glut, apparently).
Hope this helps.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.