-
sample program build problem
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.
-
Junior Member
Regular Contributor
Re: sample program build problem
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
-
Re: sample program build problem
Thank you Songho! I knew it would be something simple like that. You saved me from having a huge headache.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules