0

I am trying to write a basic C OpenGL program on mac but it is failing to compile. The code is as follows:

#define GLEW_STATIC
#include <GL/glew.h>
#include<GLFW/glfw3.h>

int main()
{
    glfwInit();
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);

    return 0;
}

But I get the error when I runn gcc test.c -o test

Undefined symbols for architecture x86_64:
  "_glfwInit", referenced from:
      _main in test-358151.o
  "_glfwWindowHint", referenced from:
      _main in test-358151.o
ld: symbol(s) not found for architecture x86_64

Can someone help?

Eli Sadoff
  • 7,173
  • 6
  • 33
  • 61
Ratan Senapathy
  • 2,148
  • 2
  • 10
  • 14
  • 1
    First thing to look at is - are you linking to the appropriate version of the OpenGL libraries for your architecture? – paisanco Nov 06 '16 at 22:25
  • Or more precise: Do you even link against glfw? This is not part of opengl and has to be installed separately. – BDL Nov 07 '16 at 00:16

0 Answers0