• 9
• 11
• 9
• 20
• 12

# openGL makefile on mac

This topic is 4214 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi all, This is my first post so I'll introduce myself a little. My name's Dean and I'm a student studying games development. I'm from Manchester in the UK. I hope to spend some time in these forums and once I actually gain some usefull knowledge I'll try and help other users out :) I'm new to openGL programming and am currently being taught it at university. However the computers at uni are running Debian and I would like to be able to do some of my work on my iBook running OSX 10.4.7 The makefile given to us for the Linux machines address the libraries/headers of the following: INCDIRS = -I/usr/X11R6/include/ LIBDIRS = -L/usr/X11R6/lib -L/usr/local/lib -L/usr/lib I was wondering where (if at all) these libraries would be on my mac so that I may change it accordingly. Thanks, Dean p.s If this is a dumb question, please tell me why ;)

##### Share on other sites
Welcome Dean to the GDnet.

Mac OS X does not install X11 at default, so it may happen that it isn't installed on your maschine yet. If so, then you have to insert the installer CDs and explicitely check installation of X11.

However, if it is installed, then AFAIK the pathes you have posted should work.

##### Share on other sites
Thanks Haegarr,

I seem to remember installing X11 a while back when trying to get 'The GIMP' to run. I've looked arround and found X11.app in my Applications/Utilities/ folder. However I'm not entirely sure how X11 works, whether I'd need some kind of SDK installed before I can use the libraries in my own code or whether its all one and the same so long as it's installed in some form or other.

Perhaps if I post the error message I receive when trying to compile my 'firstprog.c' file using the command 'make firstprog' from the terminal window, it might give you fellows in the know a better idea of what I'm doing wrong:

===
gcc -I/usr/X11R6/include/ -g -c firstprog.c -o firstprog.o
firstprog.c:1:21: error: GL/glut.h: No such file or directory
firstprog.c: In function 'display':
firstprog.c:12: error: 'GL_COLOR_BUFFER_BIT' undeclared (first use in this function)
firstprog.c:12: error: (Each undeclared identifier is reported only once
firstprog.c:12: error: for each function it appears in.)
firstprog.c:16: error: 'GL_LINES' undeclared (first use in this function)
firstprog.c: In function 'main':
firstprog.c:41: error: 'GLUT_SINGLE' undeclared (first use in this function)
firstprog.c:41: error: 'GLUT_RGB' undeclared (first use in this function)
make: *** [firstprog.o] Error 1
===

using this makefile on the same .c file in Debian works without a hitch, which is what leads me to belive either my makefile needs altering for OSX or maybe i'm missing some libraries perhaps.

Thanks again for you input,
Dean

##### Share on other sites
Hmm, I'm not sure.

X11 isn't the native windowing system for Mac OS X, of course. For my project I use the Carbon headers and frameworks, as are located in /System/Library/Frameworks. There are both OpenGL and GLUT resources. However, including the belonging headers is a little bit different from other OS'es. I personally include a GL.h file that has (besides other) the following content:
#if defined(__APPLE__)#	include <OpenGL/gl.h>#else#	include <GL/gl.h>#endif#if defined(_TRI_ARTY_USES_GLUT)#	if defined(__APPLE__)#		include <GLUT/glut.h>#	else#		include <GL/glut.h>#	endif#endif

and my makefiles deal with libraries vs. frameworks in a similar fashion.

On the other hand, besides Carbon, I'm developing for X11 but under SuSE linux. Here all the headers are located in /usr/include/ (within sub-directory GL/, as usual), and the libs are also in /usr/lib/(GL/).

Also I'm not sure whether OpenGL for X11 is installed on Mac OS if X11 itself is installed. Hmm. Seems I'm not of great help here, sorry.

##### Share on other sites
Do you want to create an X11 application or a Mac OS X application? If you want to create an X11 application, you must install the X11 SDK. The X11 SDK is on the Xcode Tools installation disc. You have to perform a custom install to install the X11 SDK. If you install the X11 SDK, your INCDIRS and LIBDIRS settings should work.

If you want to create a Mac OS X application, you must link to the OpenGL and GLUT (in your case) frameworks instead of the X11 OpenGL libraries. Use the -framework setting in your makefile to link frameworks when building your program.

You could also create an Xcode project and add the OpenGL and GLUT frameworks to it to create a Mac OS X appliction. Create either a Carbon or Cocoa application project and add the OpenGL and GLUT frameworks to it.

Mark Szymczyk
Author, Xcode Tools Sensei
Now Updated for Xcode 2.4
http://www.meandmark.com