View Full Version : sample program build problem
01-15-2006, 02:58 PM
Hey im running ubuntu and am trying to compile and run a sample opengl program. It compiles fine, but when I try to build it all these errors come up saying the same thing.
undefined reference to glBegin, glClear, glutInit, etc.
Is there something special I need to do? I know its something simple but ive never done this sort of thing before.
01-15-2006, 07:44 PM
I guess you want to know how to link libs after compiling source codes.
You need to include link option for OpenGL libraries:
-lGL -lGLU -lglut
For example, if you have only one source file, let's say "test.cpp";
g++ -o test test.cpp -lGL -lGLU -lglut
If you have more than one source files, the thing becomes more complicated. So you better have Makefile for big project.
Let's say you have 3 source files and you compiled them already;
g++ code1.o code2.o code3.o -o output -lGL -lGLU -lglut
01-15-2006, 11:26 PM
Thank you Songho! I knew it would be something simple like that. You saved me from having a huge headache.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.