title: Compiling OpenGL on Mac Error: Undefined symbols for architecture x86_64:
body: <p>I'm trying to compile a simple OpenGL code on Mac using Xcode. Previously I've used Windows. I'm getting some errors which I really have no idea about. Can some one help to fix.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;math.h&gt;
  using namespace std;
  #include &lt;OpenGL/gl.h&gt;
  #include &lt;OpenGL/glu.h&gt;
  #include &lt;OpenGL/OpenGL.h&gt;
  #include &lt;GLUT/glut.h&gt;
  
  void display (void)
  {
      glColor3f ( 1.0, 1.0, 1.0 );
  
      float angles[20] = {     30.0,45.0,60.0,75.0,90.0,105.0,120.0,135.0,150.0,165.0,180.0,195.0,210.0,225.0,240.0,255.0,270.0,285.0,300.0 };
  
  int i; float xOut, yOut, xIn, yIn; const float pi = 3.141592;
  for ( i = 0; i == 19; i++ )
  {
      float angle = angles[i]*pi/180.0;
      glBegin ( GL_LINE );
      xOut = 12 * sinf(angle);
      yOut = 12 * cosf(angle);
      xIn  =  9 * sinf(angle);
      yIn  =  9 * cosf(angle);
      glVertex3f ( xOut, yOut, 0.0);
      glVertex3f (  xIn,  yIn, 0.0);
      glEnd();
  
  }
  
  glutSwapBuffers();
  }
  
  void initializeWindow (void)
  {
  
  glClearColor (0.0, 0.0, 0.0, 0.0);
  glClear (GL_COLOR_BUFFER_BIT);
  
  glMatrixMode ( GL_PROJECTION );
  glLoadIdentity ( );
  glOrtho ( -100.0, 100.0, -100.0, 100.0, -1.0, 1.0);
  
  }
  
  
  int main(int argc, char** argv)
  {
  glutInit ( &amp;argc, argv );
  glutInitDisplayMode ( GLUT_DOUBLE | GLUT_RGB );
  glutInitWindowSize ( 500, 500 );
  glutInitWindowPosition ( 100, 100 );
  glutCreateWindow ( "PrimaryFlightDisplay" );
  
  initializeWindow ();
  
  glutDisplayFunc ( display );
  
  glutMainLoop ();
  
  return 0;
  
  }
  </code></pre>
  
  <p>I get these errors when I compile in terminal using</p>
  
  <pre><code>gcc -o main main.cpp -framework GLUT -framework OpenGL
  
  "std::ios_base::Init::Init()", referenced from:
  __static_initialization_and_destruction_0(int, int)in cczuL03z.o
  "std::ios_base::Init::~Init()", referenced from:
  ___tcf_0 in cczuL03z.o
  ld: symbol(s) not found for architecture x86_64
  collect2: ld returned 1 exit status
  </code></pre>