Light Yagami
Light Yagami

Reputation: 1043

ld: library not found for -lGL Error

In OSX, I'm working on assignment where I was asked to run make file, when I do that, I ended up with this error:Image ld: library not found for -lGL

clang: error: linker command failed with exit code 1 (use -v to see invocation)

I've installed glew and glfw3 in my OS. Can someone help me with this.

I found few similar questions but didn't get required answer. Thanks in advance.

Upvotes: 5

Views: 4278

Answers (1)

BDL
BDL

Reputation: 22175

When using OpenGL on MacOS, one has to replace -lGL with -framework OpenGL. Same goes for glut. The command should look somehow like this:

g++ -I/usr/local/include 01_triangle.cpp gl_framework.cpp shader_util.cpp -o 01_triangle -framework OpenGL -framework GLUT

Also note, that some include pathes are different on OSX. For example, the Windows/Linux includes

#include <GL/gl.h>
#include <GL/glut.h>

has to be replaced with

#include <OpenGL/gl.h>
#include <GLUT/glut.h>

Upvotes: 11

Related Questions