1. 程式人生 > >mac下安裝配置freeglut,設定xcode

mac下安裝配置freeglut,設定xcode

主要參考文章:

http://lazyfoo.net/tutorials/OpenGL/01_hello_opengl/mac/index.php

FreeGLUT doesn't have any prebuild frameworks we can use with the OS X compilers. Fortunately, Mac OS X is a type of Unix and we can use unix commands to get it to build and install freeGLUT on OS X. Unfortunatey, OS X has some quirks we need to deal with.

1)
 The first issue is that newer versions of OS X don't have X11. You'll have to install XQuartz, a quartz based port of X.org. Download the dmg and install it.

2) Download the latest source from the freeGLUT website.
Extract the archive, open a terminal window, cd to the extracted folder.

3) Configure the installation using this command in the extracted folder
env CPPFLAGS="-I/opt/X11/include" LDFLAGS="-L/opt/X11/lib" ./configure
When you installed XQuartz, it installs X11 to /opt/X11/lib. This command configures the build and tells it to look in /opt/X11/include for headers and /opt/X11/lib for library files.

4) In freeGLUT 2.8.0 there's a bug in the source code that causes to break in OS X. In the freeGLUT source directory you extracted go to progs -> demos -> smooth_opengl3 and open up smooth_openg13.c.

Between lines 101 and 102 there's a bunch type definitions that are already in glext.h that cause a conflict. typedef void (APIENTRY *PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);typedef void (APIENTRY *PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);typedef void (APIENTRY *PFNGLBUFFERDATAPROC) (GLenum target, ourGLsizeiptr size, const GLvoid *data, GLenum usage);typedef GLuint (APIENTRY *PFNGLCREATESHADERPROC) (GLenum type);typedef void (APIENTRY *PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const ourGLchar **string, const GLint *length);typedef void (APIENTRY *PFNGLCOMPILESHADERPROC) (GLuint shader);typedef GLuint (APIENTRY *PFNGLCREATEPROGRAMPROC) (void);typedef void (APIENTRY *PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);typedef void (APIENTRY *PFNGLLINKPROGRAMPROC) (GLuint program);typedef void (APIENTRY *PFNGLUSEPROGRAMPROC) (GLuint program);typedef void (APIENTRY *PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);typedef void (APIENTRY *PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, ourGLchar *infoLog);typedef void (APIENTRY *PFNGLGETPROGRAMIVPROC) (GLenum target, GLenum pname, GLint *params);typedef void (APIENTRY *PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, ourGLchar *infoLog);typedef GLint (APIENTRY *PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const ourGLchar *name);typedef void (APIENTRY *PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);typedef void (APIENTRY *PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);typedef GLint (APIENTRY *PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const ourGLchar *name);typedef void (APIENTRY *PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); All you have to do is sandwich it in some ifdef macros to make it stop complaining. #ifndef __glext_h_typedef void (APIENTRY *PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);typedef void (APIENTRY *PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);typedef void (APIENTRY *PFNGLBUFFERDATAPROC) (GLenum target, ourGLsizeiptr size, const GLvoid *data, GLenum usage);typedef GLuint (APIENTRY *PFNGLCREATESHADERPROC) (GLenum type);typedef void (APIENTRY *PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const ourGLchar **string, const GLint *length);typedef void (APIENTRY *PFNGLCOMPILESHADERPROC) (GLuint shader);typedef GLuint (APIENTRY *PFNGLCREATEPROGRAMPROC) (void);typedef void (APIENTRY *PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);typedef void (APIENTRY *PFNGLLINKPROGRAMPROC) (GLuint program);typedef void (APIENTRY *PFNGLUSEPROGRAMPROC) (GLuint program);typedef void (APIENTRY *PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);typedef void (APIENTRY *PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, ourGLchar *infoLog);typedef void (APIENTRY *PFNGLGETPROGRAMIVPROC) (GLenum target, GLenum pname, GLint *params);typedef void (APIENTRY *PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, ourGLchar *infoLog);typedef GLint (APIENTRY *PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const ourGLchar *name);typedef void (APIENTRY *PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);typedef void (APIENTRY *PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);typedef GLint (APIENTRY *PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const ourGLchar *name);typedef void (APIENTRY *PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);#endif
5)
 Then in the terminal enter the make command (make sure the terminal is in the directory you extracted)
make all
Now using root privileges, install the library with the command:
sudo make install
6) Now that you've installed the development libraries, it's time to start up your IDE/compiler. make all 出現錯誤:

smooth_opengl3.c:122:1: error:unknown type name 'PFNGLGENBUFFERSPROC'

PFNGLGENBUFFERSPROC gl_GenBuffers;

^

smooth_opengl3.c:123:1: error:unknown type name 'PFNGLBINDBUFFERPROC'

PFNGLBINDBUFFERPROC gl_BindBuffer;

^

smooth_opengl3.c:124:1: error:unknown type name 'PFNGLBUFFERDATAPROC'

PFNGLBUFFERDATAPROC gl_BufferData;

^

smooth_opengl3.c:125:1: error:unknown type name 'PFNGLCREATESHADERPROC'

PFNGLCREATESHADERPROC gl_CreateShader;

^

smooth_opengl3.c:126:1: error:unknown type name 'PFNGLSHADERSOURCEPROC'

PFNGLSHADERSOURCEPROC gl_ShaderSource;

^

smooth_opengl3.c:127:1: error:unknown type name 'PFNGLCOMPILESHADERPROC'

PFNGLCOMPILESHADERPROC gl_CompileShader;

^

smooth_opengl3.c:128:1: error:unknown type name 'PFNGLCREATEPROGRAMPROC'

PFNGLCREATEPROGRAMPROC gl_CreateProgram;

^

smooth_opengl3.c:129:1: error:unknown type name 'PFNGLATTACHSHADERPROC'

PFNGLATTACHSHADERPROC gl_AttachShader;

^

smooth_opengl3.c:130:1: error:unknown type name 'PFNGLLINKPROGRAMPROC'

PFNGLLINKPROGRAMPROC gl_LinkProgram;

^

smooth_opengl3.c:131:1: error:unknown type name 'PFNGLUSEPROGRAMPROC'

PFNGLUSEPROGRAMPROC gl_UseProgram;

^

smooth_opengl3.c:132:1: error:unknown type name 'PFNGLGETSHADERIVPROC'

PFNGLGETSHADERIVPROC gl_GetShaderiv;

^

smooth_opengl3.c:133:1: error:unknown type name 'PFNGLGETSHADERINFOLOGPROC'

PFNGLGETSHADERINFOLOGPROC gl_GetShaderInfoLog;

^

smooth_opengl3.c:134:1: error:unknown type name 'PFNGLGETPROGRAMIVPROC'

PFNGLGETPROGRAMIVPROC gl_GetProgramiv;

^

smooth_opengl3.c:135:1: error:unknown type name 'PFNGLGETPROGRAMINFOLOGPROC'

PFNGLGETPROGRAMINFOLOGPROC gl_GetProgramInfoLog;

^

smooth_opengl3.c:136:1: error:unknown type name 'PFNGLGETATTRIBLOCATIONPROC'

PFNGLGETATTRIBLOCATIONPROC gl_GetAttribLocation;

^

smooth_opengl3.c:137:1: error:unknown type name 'PFNGLVERTEXATTRIBPOINTERPROC'

PFNGLVERTEXATTRIBPOINTERPROC gl_VertexAttribPointer;

^

smooth_opengl3.c:138:1: error:unknown type name

      'PFNGLENABLEVERTEXATTRIBARRAYPROC'

PFNGLENABLEVERTEXATTRIBARRAYPROC gl_EnableVertexAttribArray;

^

smooth_opengl3.c:139:1: error:unknown type name 'PFNGLGETUNIFORMLOCATIONPROC'

PFNGLGETUNIFORMLOCATIONPROC gl_GetUniformLocation;

^

smooth_opengl3.c:140:1: error:unknown type name 'PFNGLUNIFORMMATRIX4FVPROC'

PFNGLUNIFORMMATRIX4FVPROC gl_UniformMatrix4fv;

^

fatal error: too many errors emitted, stopping now [-ferror-limit=]

20 errors generated.

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。沒有報錯。make install.

再參考:

http://lazyfoo.net/tutorials/OpenGL/01_hello_opengl/mac/xcode/index.php

1)Start up XCode and create a command line tool project.

Remove the main.cpp file autogenerated for the project as we're not using it. Go download the source for lesson 01. Add the source files inside to your project.

2)Click on your project to reveal the Build Settings tab. Click on the Build Settings tab. Under in the Linking section in the Other Linker Flags add -lGLUT. This will make the project link with the freeGLUT Unix library we installed.
3)In the Search Paths section add
"/opt/X11/include" "/usr/local/include"
to the Header Search Paths and
"/opt/X11/lib" "/usr/local/lib"
to the Library Search Paths
This makes it so XCode will find the header/library files for XQuartz (/opt/X11/) and freeGLUT (/usr/local/).

4)Click on the Build Phases Tab, open up Link Binary with Libraries and add the OpenGL framework.
Now build. If there are any errors, make sure you didn't skip a step.

Now that you have OpenGL and freeGLUT compiling, it time to go onto part 2 of the tutorial. 該步很順利,"/opt/X11/lib" "/usr/local/lib"
to the Library Search Paths,圖片顯示有誤

相關推薦

mac安裝配置freeglut,設定xcode

主要參考文章: http://lazyfoo.net/tutorials/OpenGL/01_hello_opengl/mac/index.php FreeGLUT doesn't have any prebuild frameworks we can use with

mac安裝配置go開發環境

string hello pkg obi cin keyword art ces mac 1、官網下載安裝包(需FQ)   https://storage.googleapis.com/golang/go1.7.darwin-amd64.pkg 2、配置Go環境變量GOPA

mac安裝配置nginx,php環境

服務 端口 通過 etc 安裝 set cnblogs fast ocr 1、安裝nginx 在mac系統下我們使用brew來安裝nginx,使用brew來安裝,它會自動安裝相應的依賴庫。 brew install nginx 在安裝完畢後,終端會輸出配置信息: Doc

01.mac安裝配置maven

第一步:下載maven包 maven 3.3 下載地址 https://archive.apache.org/dist/maven/maven-3/ maven 最新下載地址 http://maven.apache.org/download.cgi# 第二步:解壓maven包並放入到硬碟任意

Mac安裝配置Python2和Python3並相互切換使用

  mac os 以前沒有使用過,這次使用了一把,的確還是比較不順手的,估計從今以後,就要把平臺逐漸切換到mac了。今後好的文章,專門會開一個macos專欄,專門記錄macos的使用過程中的心得,體會,以及遇到的一些問題總結。     一般是python2預設安裝了,python3沒有安

mac安裝配置和使用zsh+autojump

1,安裝zsh,執行 sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" 2,安裝autojump,執行 brew install aut

Mac安裝配置MongoDB

1.去官方網站下載最新版的Mac版的MongoDB:mongodb-osx-x86_64-2.2.0.tgz。MongoDB的官方網站:www.mongodb.org。2.解壓mongodb的壓縮包到某個安裝目錄,例如:/Users/circle/Develope-Tools

mac os 10.13安裝配置cocoapods並在xcode中使用

關閉SIP保護 10.3.4版本下macOS開啟了SIP保護,即便是root使用者也不能修改系統目錄中的檔案,所以要安裝cocoapods,需要先關閉這個服務 方法如下 1. 重啟電腦按住comm

Mac安裝MySQL(含配置

.tar.gz 界面 take 8.4 通過 -1 pass 查看 pack 首先需要下載 MySQL Community Server 下載地址:https://dev.mysql.com/downloads/mysql/ 進入MySQL的下載界面(https:

mac安裝Maven和配置環境變量

環境變量 java環境 targe download 查看 window bsp 編輯 配置 1、下載maven包:   下載鏈接:??http://maven.apache.org/download.cgi   maven下載文件釋義:     1?? Binary ta

Mac安裝配置Redis

bsp 連接 遠程 post ret 執行 don redis 命令 rfi 使用Homebrew安裝redis可以減少大量的安裝和配置的工作量。 檢測是否安裝了homebrew   brew -v 安裝命令   brew install redis 安裝完

Linux伺服器安裝配置SVN並設定開機啟動

下面以CentOS7.5為例介紹SVN的安裝步驟。 一、安裝svn伺服器 在Linux中安裝服務端 yum install subversion 二、配置SVN伺服器 1、新建一個版本倉庫(名字可以任意取) mkdir /svn svnadmin create /svn/pr

Mac安裝zsh之後配置環境變數失效問題

解決方法: 因為安裝zsh,~/.bash_profile就不會被執行,解決辦法有兩種: 1.vim ~/.zshrc 將你要配置到環境變數配置到該檔案中即可 2.vim ~/.zshrc 將 source ~/.bash_profile 新增到末尾,這樣~/.bash_profil

Mac OS X安裝配置Android原始碼開發環境

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!        

Mac 安裝Tomcat並配置環境

1.下載Tomcat(http://tomcat.apache.org/download-80.cgi) 2.解壓unzip xxxx.zip 3.把檔案移到Library的目錄下便於管理 3.1 mv 上一步解壓的檔名 ~/Library/新的檔名 3.1.1 事例:

mac 安裝rabbitmq 和配置php擴充套件

看到網上大部分都是需要先安裝很多下載工具,感覺麻煩,我mac 上一直都僅用homebrew 管理和安裝第三方的。這裡分享一下步驟: 安裝rabbitmq 方式: brew  install rabbitmq 安裝成功後可以先啟動前臺任務:rabbitmq-server ,

Mac 安裝配置 Tomcat

1,下載 點選 官網 ,進入下載頁面, 2,安裝 解壓出來,即安裝完成。 移動解壓後的檔案,換個檔案目錄(方便集中管理),將它改個名字(畢竟名字太長了)。 我將其改名為 tomcat9 ,移入資源庫目錄下,這也是 Java 安裝的預設位置。 3,驗證 開啟 終端 app ,執行 /

mac安裝anaconda3+tensorflow+keras,並配置pycharm工程

目錄 1、anaconda3安裝 (1)安裝 (2)檢查是否成功安裝 2、tensorflow安裝 (1)建立tensorflow環境,設定與python版本對應的tensorflow (2)安裝好之後,啟用tensorflow環境,再安裝tensorflow (3)驗證

Mac安裝配置Eclipse

1.安裝Eclipse前先確認你的Mac上是否已安裝java執行環境。進入終端,輸入”java -version”,如果返回了java版本號則說明已安裝,否則,請先安裝java執行環境: 3.這裡列出了多種下載安裝包,根據你的需求來選擇。由於我們需要開發基於web的jsp程式,所以要選擇Java

Mac 安裝mongodb及配置

# 1 mongodb官網下載mac安裝包 wget https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-4.0.4.tgz # 2 解壓 su