2012-02-05 96 views
5

我在做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

回答

5

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

4

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

1

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 
相關問題