views:

59

answers:

1

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
+1  A: 

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.

Alexandre Jasmin
Yeah just realized that it would have compiled correctly if I fixed my typo in the includes :P. Thanks anyways though, this makes it run natively.
Jamie