title: Why do I get an undefined reference( to `glColor3f' ,for example) when I compile a program in c?
body: <p>I'm compiling an example program that uses opengl in ubuntu (linux). A short snippet of the code is the following:</p>
  
  <pre><code> #include &lt;stdlib.h&gt; 
  
   #include &lt;GL/glut.h&gt;
  
  
   void createBox( GLfloat centroX, GLfloat centroY,
                         GLfloat corR, GLfloat corG, GLfloat corB )
   {
      /* Cor  */
  
      glColor3f( corR, corG, corB );
  </code></pre>
  
  <p>I've installed all of the packages to develop in opengl (in ubuntu), namely:</p>
  
  <pre><code>freeglut3 freeglut3-dev libglew1.5 libglew1.5-dev libglu1-mesa
  libglu1-mesa-dev libgl1-mesa-glx libgl1-mesa-dev
  </code></pre>
  
  <p>I compile the example like this:</p>
  
  <pre><code>gcc -lGL   CG_ex04.c -o main
  </code></pre>
  
  <p>and I get the following</p>
  
  <pre><code>/tmp/ccDWmJDZ.o: In function `createBox':
  CG_ex04.c:(.text+0x31): undefined reference to `glColor3f'
  </code></pre>
  
  <p>and other errors along the same line.</p>
  
  <p>Does anyone know what I'm doing wrong?</p>
  
  <p>Thanx in advance for any help.</p>