# need help with setting up GLUT/OpenGL on Mac OS X



## y10k (Jan 21, 2007)

I am taking a computer graphics course this semester and the assignments are designed to work on Linux and Windows.

I am wondering if it is possible to compile this on Mac OS X.

Attached is the assignment files, including a GLUI include files.

Any clue how I can compile this on Mac?

---------------

updated:

I have compiled the program. However, when I runned it the following errors were showed: 



[Session started at 2007-01-21 17:21:55 -0500.]
Usage: demo [width] [height]
Using 300x200 window by default...
2007-01-21 17:21:56.027 monkey[2314] GLUT Fatal Error: internal error: NSInternalInconsistencyException, reason: Error (1002) creating CGSWindow


After Google I suspect this is because the cocoa layer is not initialized and can probably be solved by adding NSApplicationLoad.

I don't know how I can add that function since this is the first time I program on Mac.


----------



## szymczyk (Jan 21, 2007)

Create a C++ Tool project (or Standard Tool project if you're using C instead of C++) in Xcode. Add the OpenGL and GLUT frameworks to your project. That should be enough to compile GLUT code on Mac OS X.


----------



## y10k (Jan 21, 2007)

szymczyk said:


> Create a C++ Tool project (or Standard Tool project if you're using C instead of C++) in Xcode. Add the OpenGL and GLUT frameworks to your project. That should be enough to compile GLUT code on Mac OS X.




How should I change the include files?

#include <GL/gl.h>

#include <GL/glu.h>

#include <GL/glut.h>

It shows 

error: GL/gl.h: No such file or directory
error: GL/glu.h: No such file or directory
etc..


----------



## y10k (Jan 21, 2007)

y10k said:


> How should I change the include files?
> 
> #include <GL/gl.h>
> 
> ...




It compiled after I changed all the include <GL/...> to include <GLUT/...>

However, when I runned the program, it showed:

[Session started at 2007-01-21 16:41:47 -0500.]
ZeroLink: unknown symbol '_GLUI_Master'

monkey has exited due to signal 6 (SIGABRT).


----------



## Mikuro (Jan 21, 2007)

Try this:

	#import <OpenGL/gl.h>
	#import <OpenGL/glu.h>
	#import <GLUT/glut.h>


----------



## y10k (Jan 21, 2007)

After lots of tweaking, I can compiile the program now.

However, when it runs, it shows:

[Session started at 2007-01-21 17:21:55 -0500.]
Usage: demo [width] [height]
Using 300x200 window by default...
2007-01-21 17:21:56.027 monkey[2314] GLUT Fatal Error: internal error: NSInternalInconsistencyException, reason: Error (1002) creating CGSWindow


How can I resolve this problem?


----------



## macbri (Jan 31, 2007)

I used Fink to install glut and glui packages:


```
fink install glut glut-shlibs glui glui-shlibs
```

Then I edited monkey.cpp similar to Mikuro's suggestion :


```
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#include <glui.h>
```
 and the Makefile to search /sw/include and /sw/lib for headers and libraries respectively (which is where Fink installs stuff):


```
CPPFLAGS      = -I/sw/include
GL_LIBS       = -L/sw/lib -lGLU -lGL -lglut -lglui
```

It compiled with some warnings but otherwise ok.  Ran fine from an Xterm and I even captured the 'proof' for ya


----------



## kangaechigai (Oct 29, 2008)

y10k said:


> GLUT Fatal Error: internal error: NSInternalInconsistencyException, reason: Error (1002) creating CGSWindow



When I had this error, I found one potential solution at http://www.idevgames.com/forum/archive/index.php/t-6635.html. Apparently 
	
	



```
glutInit(&argc, argv);
```
 must be called in your main before you can create a window, but this seems not to be necessary on many other platforms, so it's left out of a lot of sample code.


----------

