Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert this OpenGL makefile from Linux to Mac OS X?

I'm trying to compile a OpenGL program on my MacBook and can't figure out how to convert this makefile.

CFLAGS= -I/usr/X11R6/include -I/usr/local/include
LDFLAGS= -L/usr/X11R6/lib -L/usr/local/lib -lGL -lGLU -lm -lglut 

BINARIES=q2

all: $(BINARIES)

clean: 
 -rm *.o $(BINARIES)

q2 : q2.o 
 g++ $(LDFLAGS) $^ -o q2 

q2.o: q2.cpp 
 g++ -c $(CFLAGS) q2.cpp

depend:
 makedepend *.cpp
like image 563
Jamie Curtis Avatar asked Oct 23 '10 20:10

Jamie Curtis


1 Answers

Change the source code

#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

Don't include GL.h or GLU.h. glut.h should pull them for you regardless of the platform.

And change your Makefile

CFLAGS= 
LDFLAGS= -framework GLUT -framework OpenGL -framework Cocoa 

Note that I was also able to build something using your original Makefile but I think that's because I have Apple X11 installed.

like image 73
Alex Jasmin Avatar answered Oct 20 '22 15:10

Alex Jasmin