是否可以在Mac OS X上构建FreeGLUT?

问题描述:

我在做some tutorials on OpenGL,使用FreeGLUT是否可以在Mac OS X上构建FreeGLUT?

Apparently这是你如何建立并在Mac上安装它:

CPPFLAGS="-I/usr/X11R6/include" ./configure --prefix="${PWD}/../" 
make 
make install 

可惜这对自己给了我一个错误,当我做make命令:Undefined symbols for architecture x86_64

做工作升技后我发现第一行的改进是:

CPPFLAGS="-I/usr/X11R6/include -L/usr/X11R6/lib" LDFLAGS="-L/usr/X11R6/lib" ./configure --prefix="${PWD}/../" 

不幸的是,当我做make命令我仍然得到一个错误:

gcc -DHAVE_CONFIG_H -I. -I../../.. -I/usr/X11R6/include -L/usr/X11R6/lib -I../../../include -g -O2 -Wall -pedantic -MT smooth_opengl3-smooth_opengl3.o -MD -MP -MF .deps/smooth_opengl3-smooth_opengl3.Tpo -c -o smooth_opengl3-smooth_opengl3.o `test -f 'smooth_opengl3.c' || echo './'`smooth_opengl3.c 
smooth_opengl3.c:101: error: redefinition of typedef ‘PFNGLGENBUFFERSPROC’ 
/usr/X11R6/include/GL/glext.h:5080: error: previous declaration of ‘PFNGLGENBUFFERSPROC’ was here 
smooth_opengl3.c:102: error: redefinition of typedef ‘PFNGLBINDBUFFERPROC’ 
/usr/X11R6/include/GL/glext.h:5078: error: previous declaration of ‘PFNGLBINDBUFFERPROC’ was here 
smooth_opengl3.c:103: error: redefinition of typedef ‘PFNGLBUFFERDATAPROC’ 
/usr/X11R6/include/GL/glext.h:5082: error: previous declaration of ‘PFNGLBUFFERDATAPROC’ was here 
smooth_opengl3.c:104: error: redefinition of typedef ‘PFNGLCREATESHADERPROC’ 
/usr/X11R6/include/GL/glext.h:5197: error: previous declaration of ‘PFNGLCREATESHADERPROC’ was here 
smooth_opengl3.c:105: error: redefinition of typedef ‘PFNGLSHADERSOURCEPROC’ 
/usr/X11R6/include/GL/glext.h:5222: error: previous declaration of ‘PFNGLSHADERSOURCEPROC’ was here 
smooth_opengl3.c:106: error: redefinition of typedef ‘PFNGLCOMPILESHADERPROC’ 
/usr/X11R6/include/GL/glext.h:5195: error: previous declaration of ‘PFNGLCOMPILESHADERPROC’ was here 
smooth_opengl3.c:107: error: redefinition of typedef ‘PFNGLCREATEPROGRAMPROC’ 
/usr/X11R6/include/GL/glext.h:5196: error: previous declaration of ‘PFNGLCREATEPROGRAMPROC’ was here 
smooth_opengl3.c:108: error: redefinition of typedef ‘PFNGLATTACHSHADERPROC’ 
/usr/X11R6/include/GL/glext.h:5193: error: previous declaration of ‘PFNGLATTACHSHADERPROC’ was here 
smooth_opengl3.c:109: error: redefinition of typedef ‘PFNGLLINKPROGRAMPROC’ 
/usr/X11R6/include/GL/glext.h:5221: error: previous declaration of ‘PFNGLLINKPROGRAMPROC’ was here 
smooth_opengl3.c:110: error: redefinition of typedef ‘PFNGLUSEPROGRAMPROC’ 
/usr/X11R6/include/GL/glext.h:5223: error: previous declaration of ‘PFNGLUSEPROGRAMPROC’ was here 
smooth_opengl3.c:111: error: redefinition of typedef ‘PFNGLGETSHADERIVPROC’ 
/usr/X11R6/include/GL/glext.h:5209: error: previous declaration of ‘PFNGLGETSHADERIVPROC’ was here 
smooth_opengl3.c:112: error: redefinition of typedef ‘PFNGLGETSHADERINFOLOGPROC’ 
/usr/X11R6/include/GL/glext.h:5210: error: previous declaration of ‘PFNGLGETSHADERINFOLOGPROC’ was here 
smooth_opengl3.c:113: error: redefinition of typedef ‘PFNGLGETPROGRAMIVPROC’ 
/usr/X11R6/include/GL/glext.h:5207: error: previous declaration of ‘PFNGLGETPROGRAMIVPROC’ was here 
smooth_opengl3.c:114: error: redefinition of typedef ‘PFNGLGETPROGRAMINFOLOGPROC’ 
/usr/X11R6/include/GL/glext.h:5208: error: previous declaration of ‘PFNGLGETPROGRAMINFOLOGPROC’ was here 
smooth_opengl3.c:115: error: redefinition of typedef ‘PFNGLGETATTRIBLOCATIONPROC’ 
/usr/X11R6/include/GL/glext.h:5206: error: previous declaration of ‘PFNGLGETATTRIBLOCATIONPROC’ was here 
smooth_opengl3.c:116: error: redefinition of typedef ‘PFNGLVERTEXATTRIBPOINTERPROC’ 
/usr/X11R6/include/GL/glext.h:5280: error: previous declaration of ‘PFNGLVERTEXATTRIBPOINTERPROC’ was here 
smooth_opengl3.c:117: error: redefinition of typedef ‘PFNGLENABLEVERTEXATTRIBARRAYPROC’ 
/usr/X11R6/include/GL/glext.h:5202: error: previous declaration of ‘PFNGLENABLEVERTEXATTRIBARRAYPROC’ was here 
smooth_opengl3.c:118: error: redefinition of typedef ‘PFNGLGETUNIFORMLOCATIONPROC’ 
/usr/X11R6/include/GL/glext.h:5212: error: previous declaration of ‘PFNGLGETUNIFORMLOCATIONPROC’ was here 
smooth_opengl3.c:119: error: redefinition of typedef ‘PFNGLUNIFORMMATRIX4FVPROC’ 
/usr/X11R6/include/GL/glext.h:5242: error: previous declaration of ‘PFNGLUNIFORMMATRIX4FVPROC’ was here 
make[4]: *** [smooth_opengl3-smooth_opengl3.o] Error 1 
make[3]: *** [all-recursive] Error 1 
make[2]: *** [all-recursive] Error 1 
make[1]: *** [all-recursive] Error 1 
make: *** [all] Error 2 

这一直是documented on the net before,但解决的办法是不是真的在这种情况下是有帮助的。我也尝试将它换成OS X附带的GLUT.framwork,但是这些示例使用FreeGLUT特定的函数。

+0

好吧,我已经在这个有远一点。使用'CPPFLAGS =“ - I/usr/X11R6/include -L/usr/X11R6/lib”./configure --prefix =“$ {PWD} /../”'摆脱'Undefined symbols'错误。但是现在我得到'ld:library没找到-lGL' \'collect2:ld返回1退出状态'''make [2]:*** [libglut.la]错误1''make [1]:* ** [all-recursive]错误1' /'make:*** [all]错误2' – bjz 2012-02-06 03:39:28

+1

也许你还应该检查LDFLAGS,需要'-L/usr/X11R6/lib'。 – ZhangChn 2012-02-06 05:37:48

+0

噢,谢谢。好的,我用'CPPFLAGS =“ - I/usr/X11R6/include -L/usr/X11R6/lib”LDFLAGS =“ - L/usr/X11R6/lib”./configure --prefix =“$ {PWD}/../“',我摆脱了以前的错误。现在我得到了一个错误:'smooth_opengl3.c:101:error:重新定义typedef'PFNGLGENBUFFERSPROC'' /usr/X11R6/include/GL/glext.h:5080:错误:以前的声明'PFNGLGENBUFFERSPROC'在这里' – bjz 2012-02-06 07:08:24

XQuartz 2.7.2交换到FreeGLUT(2.8.0),而不是老MesaGLUT。因此,如果您拥有OS X 10.6.3或更高版本,则只需安装XQuartz 2.7.2或更高版本即可。请参阅:

+0

对于那些想知道如何在XCode中设置freeglut的人,请参阅http://lazyfoo.net/tutorials/OpenGL/01_hello_opengl/mac/xcode/index.php – zhangyoufu 2014-10-22 11:47:01

It was suggested在Xquartz的邮件列表中,声明freeglut演示是错误的声明那些PFN * PROC两次。

因此,通过简单地注释掉smooth_opengl3.c中的那些双重定义,空闲的过剩将通过编译阶段。但是,从我的经验来看,它不会运行,并给出GLSL的一些错误。

也有人认为GLUT framework should be used在Mac OS X

+0

不幸的是,OSX的GLUT框架不支持OpenGL 3.2。 – 2012-08-25 21:53:46

It's我正与以下参数配置:

./configure CFLAGS="-I/usr/X11/include/X11/extensions -L/usr/X11/lib" LIBS="-lXrandr -lXxf86vm -lXi" --with-x --x-includes=/usr/X11/include