MAC 10.7: gl.h文件在哪里?

3

可能重复:
在Mac OS X Lion上使用FreeGLUT

首先的问题是:为什么我无法在我的Mac上找到gl.h文件?如果这个问题可以简单回答,那么您甚至不需要阅读剩余的内容,但我在网上找不到任何答案(经过几个小时的研究),除了著名的“它已集成到操作系统中”之类的说法。


我的问题详细说明:

我在使用OpenGL编译.c文件时遇到了问题。我已经在网上浏览了几个小时,但没有找到任何解决方案。以下是问题:

对于那些了解这个软件的人来说,我正在使用Webots(一个机器人仿真软件),并且我想实现一个物理插件。我从一个已经存在(且正常工作)的插件中复制了代码,只是为了尝试一下。我使用Webots进行编译,它使用gcc(因为Xcode不再附带gcc编译器,所以我不得不安装gcc编译器)。

现在的问题是,.c文件包括一个“physics.h”头文件,该文件包含OpenGL/gl.h文件,然后我就会出现错误:“OpenGL/gl.h:没有这样的文件或目录”。

现在我已经尝试了很多方法:

  • 搜索gl.h文件:似乎它不存在(我无法找到它,无论是手动还是使用查找功能)

  • 将包含OpenGL/gl.h的语句替换为GLUT/glut.h:我收到错误消息“gl.h和glu.h没有这样的文件或目录”,因为它们被包含在glut.h中

  • 在makefile和框架中链接gl库

  • 可能是所有这些组合,使用绝对路径或相对路径!

由于OpenGL和GLUT应该与操作系统一起安装(我使用的是Lion 10.7.5),所以我认为每个需要的文件都应该在那里。因此,我找不到下载这个所谓缺失的文件的方法...

此外,我的同事尝试在Linux上编译它并成功了! Linux是一个很棒的平台,但我仍然喜欢我的Mac,所以请让我希望有另一种解决方案而不是转向Linux!!!

我认为我的问题要么在Makefile中,要么在physic.h文件中,所以它们在这里:

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

附言:在我试图编译的“my_contact_p_physics.c”(.c文件)中,我只需包含ODE / ode.h文件和physics.h文件,并使用绝对路径。由于ODE已经“集成”到Webots中,我无法直接在终端中进行编译,这就是为什么我直接在Webots中进行编译的原因。


你需要将OpenGL框架添加到你的项目中。 - datenwolf
这不是由我在Makefile中编写的吗?即:FRAMEWORK:-framework OpenGL - Wat
1个回答

7

gl.h文件已经在这里了,就在/System/Library/Frameworks/OpenGL.framework/Headers目录下。你可以使用-framework OpenGL,或者将-I /System/Library/Frameworks/OpenGL.framework/Headers添加到编译器标志中。假设你的文件已经存在(默认情况下是存在的),你应该能够找到它并且一切都能正常工作!


2
谢谢你的回答。我已经查看了OpenGL.framework,但问题是我没有“Headers”目录。我只有Version/A/,在那里我有“_CodeSignature”,“Libraries”(包含一些OpenGL库但没有头文件),OpenGL(可执行文件),“Plugins”目录,“Resources”目录。它们都不包含任何头文件。你认为卸载并重新安装Xcode会有帮助吗?顺便说一下,我在GLUT.framework中有一个Headers目录,但只有glut.h在那里(它包括gl.h和glu.h)。 - Wat

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接