ld: library not found for -lGL Error
Asked Answered
B

1

5

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.

Bicknell answered 7/8, 2018 at 9:8 Comment(1)
if you use cmake, you can just find_package(OpenGL REQUIRED) and it will "do the right thing" cmake.org/cmake/help/v3.10/module/FindOpenGL.htmlDeclarer
P
11

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>
Playbook answered 7/8, 2018 at 9:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.