Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling a C program that uses OpenGl in Mac OS X

Tags:

c

macos

gcc

opengl

I am trying to compile a C program for my CS class. I have Command Line tools installed on my Mac, so I probably have OpenGL. The program description was made for Ubuntu and it says for me to compile using:

gcc -Wall -ansi -pedantic -O2 main.o graphic.o imagem.o io.o -o ep2 -lGL -lGLU -lglut

I ran that and it said:

ld: library not found for -lGL

What flags should I use? What do I do?

like image 764
Thi G. Avatar asked Aug 31 '13 16:08

Thi G.


People also ask

Can you run OpenGL on Mac?

According to Apple, OpenGL is no longer supported. However, it appears v4. 1 of OpenGL was supported on many devices as of July 28, 2020.

Can you compile C on Mac?

C code can be written in any platform like Mac, Windows, etc. C compilers compile C code and create an executable according to the platform. The executable created for one platform can only be executed on that platform. Following are different Mac C compilers.

How do I compile gcc on Mac?

In OS X, GCC is part of Xcode's command tools, so first, open the Mac App Store and install Xcode for free. Then, open Xcode, go to Xcode menu (on the menu bar) > Preferences > Downloads, and install Command Line Tools. You will get commands like gcc, make, purge... Thank u dude once again!!!


1 Answers

I found you have to use

-framework OpenGL -framework GLUT

Reference

like image 176
Mike Lee Avatar answered Sep 27 '22 20:09

Mike Lee