Problems using GLFW and XCode : won't compile

2019-09-02 01:37发布

问题:

I have been programming in C for a while, but now I come to GLFW and OpenGL and everything goes wrong.

I am using OSX Snow Leopard and XCode, compiling with GCC.

I added to the project the following frameworks to be sure everything is there : Cocoa, OpenGL, GLUT, AGL and Carbon.

Under XCode, I put under the Header search paths: /usr/local/include

And I put under the Library search paths : /usr/local/lib, /usr/local/lib/pkgconfig and /Users/Arkady/Desktop/glfw-2.7.2/lib (I know it is probably too much, but it seems GCC can't find the functions...).

When compiling, I get 5 errors :

Undefined symbols:
  "_glfwSwapBuffers", referenced from:
      _glfemPlotReshape in glfem.o
  "_glfwOpenWindow", referenced from:
      _glfemInit in glfem.o
  "_glfwInit", referenced from:
      _glfemInit in glfem.o
  "_glfwSetWindowSizeCallback", referenced from:
      _glfemInit in glfem.o
  "_glfwSetWindowTitle", referenced from:
      _glfemInit in glfem.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

I haven't forgot to put the #include <GL/glfw.h> in the code.

I have now been searching for two hours on the Internet, it's enough. I really hope you will bring me the answer : what did I forget to give GCC so that he cannot find the functions?

回答1:

This is a linker error, you have to link your program with the glfw libraries.

See Link with the right libraries here

http://www.glfw.org/docs/latest/build.html#build_link



标签: c xcode glfw