Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: sample program build problem

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2006
    Posts
    2

    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.

  2. #2
    Junior Member Regular Contributor songho's Avatar
    Join Date
    May 2003
    Location
    Canada
    Posts
    247

    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

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2006
    Posts
    2

    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
  •