MAC 10.7 : Where is the gl.h file?

12.9k Views Asked by At

Possible Duplicate:
FreeGLUT on Mac OS X Lion

First quizz : could anyone just please explain me why am I not able to find the gl.h file anywhere on my mac ?! If this question can simply be answered maybe you do not even have to read the rest, but I couldn't find any answer on the web to that one (after hours of research), except the famous "it's integrated into the os" or something like that.


My problem In detail:

I am having an issue with the compilation of a .c file using OpenGL. Ihave browsed the web for hours without finding any solution. Here is the problem :

For those who know this software, I am using Webots (a robot simulation software) and I would like to implement a physic plugin. I copied the code from an already existing (and working) plugin, just to try it out. I am compiling with webots, which uses a gcc (I had to install a gcc compiler since it doesn't come with Xcode anymore).

Now, the problem is that the .c file includes a "physics.h" header which includes the OpenGL/gl.h file and I then get the error : "OpenGL/gl.h . no such file or directoy".

Now I've tried to many things :

  • making a search for gl.h : it seems it doean't exist (I can't find it, either manually or with the finder search function)

  • replacing the include OpenGL/gl.h by GLUT/glut.h : I get the error "gl.h and glu.h no such fil or directory" since their included in the glut.h

  • linking the gl libraries in the makefile and the frameworks as well

  • Probably all the combination of these, using absolute or relative path !

Since OpenGL and GLUT are supposed to be natively installed with OS (I am on using Lion 10.7.5) I guess every needed file should be there. And for this reaon I cannot find a way to download this supposedely missing file...

Moreover a coworker of mine tried and successfully compiled it on linux ! Linux is a great platform but I still love my mac, so please let me hope there is another solution than to change for linux !!!

I think my problem lies either in the Makefile or in the physic.h file, so here they are :

Physic.h:

#ifndef PHYSICS_H
#define PHYSICS_H
#include <ode/ode.h>
#ifdef WIN32
#include <windows.h>
#endif
#ifndef MACOS
#include <GL/gl.h>
#else
#include <OpenGL/gl.h>
#endif

/* callback functions to be implemented in your physics plugin */
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _MSC_VER
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT
#endif
DLLEXPORT void webots_physics_init(dWorldID,dSpaceID,dJointGroupID);
DLLEXPORT int  webots_physics_collide(dGeomID,dGeomID);
DLLEXPORT void webots_physics_step();
DLLEXPORT void webots_physics_step_end();
DLLEXPORT void webots_physics_cleanup();
DLLEXPORT void webots_physics_draw();
DLLEXPORT void webots_physics_predraw();

/* utility functions to be used in your callback functions */
#ifndef LINUX
extern dGeomID (*dWebotsGetGeomFromDEFProc)(const char *);
extern dBodyID (*dWebotsGetBodyFromDEFProc)(const char *);
extern void    (*dWebotsSendProc)(int,const void *,int);
extern void*   (*dWebotsReceiveProc)(int *);
extern void    (*dWebotsConsolePrintfProc)(const char *, ...);
extern double  (*dWebotsGetTimeProc)();
#define dWebotsGetGeomFromDEF(DEFName)    (*dWebotsGetGeomFromDEFProc)(DEFName)
#define dWebotsGetBodyFromDEF(DEFName)    (*dWebotsGetBodyFromDEFProc)(DEFName)
#define dWebotsSend(channel,buff,size)    (*dWebotsSendProc)(channel,buff,size)
#define dWebotsReceive(size_ptr)          (*dWebotsReceiveProc)(size_ptr)

#if defined(__VISUALC__) || defined (_MSC_VER) || defined(__BORLANDC__)
#define dWebotsConsolePrintf(format, ...) (*dWebotsConsolePrintfProc)(format, __VA_ARGS__)
#else
#define dWebotsConsolePrintf(format, ...) (*dWebotsConsolePrintfProc)(format, ## __VA_ARGS__)
#endif

#define dWebotsGetTime()                  (*dWebotsGetTimeProc)()
#else
dGeomID dWebotsGetGeomFromDEF(const char *DEFName);
dBodyID dWebotsGetBodyFromDEF(const char *DEFName);
void    dWebotsSend(int channel,const void *buffer,int size);
void   *dWebotsReceive(int *size);
void    dWebotsConsolePrintf(const char *format, ...);
double  dWebotsGetTime();
#endif
#ifdef __cplusplus
}
#endif

#endif /* PHYSICS_H */

Makefile:

###
### Standard Makefile for Webots physics plugins
###
### Supported platforms: Windows, Mac OS X, Linux
### Supported languages: C, C++
### 
### Authors: Olivier Michel - www.cyberbotics.com
### Revised: Yvan Bourquin - September 30th, 2009.
###
### Uncomment the variables to customize the Makefile

### -----C Sources-----
###
### if your plugin uses several C source files:
 C_SOURCES = my_contact_p_physics.c

### -----C++ Sources-----
###
### if your plugin uses several C++ source files:
# CPP_SOURCES = my_plugin.cpp my_clever_algo.cpp my_graphics.cpp
###     or
# CC_SOURCES = my_plugin.cc my_clever_algo.cc my_graphics.cc

FRAMEWORK = -framework OpenGL -framework GLUT 

### -----Options-----
###
### if special CFLAGS are necessary, for example to set optimization level or
### to find include files:
#CFLAGS=-O3 -I/System/Library/Frameworks/OpenGL.framework
###
### if your plugin needs additional libraries:
LIBRARIES=-L/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries -llibGL -llibGLU


### Do not modify: this includes Webots global Makefile.include
space :=
space +=
WEBOTS_HOME_PATH=$(subst $(space),\ ,$(strip $(subst \,/,$(WEBOTS_HOME))))
include $(WEBOTS_HOME_PATH)/resources/projects/default/plugins/physics/Makefile.include

P.S: In the "my_contact_p_physics.c" (the .c file I am trying so hard to compile) I simply include a ODE/ode.h file and the physics.h file with absolute path. I cannot compile directy in the terminal because of the ODE which "integrated" into webots, reason why I compile in webots directly.

1

There are 1 best solutions below

1
On

The gl.h is there, alright - Just in /System/Library/Frameworks/OpenGL.framework/Headers. Either use -framework OpenGL, or add -I /System/Library/Frameworks/OpenGL.framework/Headers to the compiler flags. Assuming your file is there (which it is, by default), you should find it, and all should work!