主要參考此網頁, 安裝成功之作業系統為OS X 10.10.3
1. 安裝Homebrew
- 開啟terminal (以Spotlight搜尋terminal.app)
- 將官網之script(
ruby -e "...
)貼至terminal執行 - 按指示完成安裝, 會順便灌好xcode, xcode command line tools, git ...
2. (於terminal) brew update
取得最新版的Homebrew, 我不確定剛下載好是不是需要update.., 但就update吧
3. brew install qt5
經過漫長的下載, 編譯後將Qt安裝在/usr/local/opt/qt5
4. brew linkapps
通過此步驟才能在應用程式找到Assistant, Designer, Linguist.. 雖然說有了Creator我從沒開過Assistant, Designer, 但Spotlight不知為何連不到Designer, Assistant, 還是link一下好
以下說明Creator安裝方法
5. brew install caskroom/cask/qt-creator
正常好像會先brew install caskroom/cask/brew-cask
把cask裝好, 但上述步驟應可直接裝好cask, 再裝Qt Creator
再來要於Qt Creator設定使用的Qt版本(qmake位置)及編譯器
6. 開啟Qt Creator(用Spotlight), 選螢幕上方的"工具"-"外部"-"Configure", 開啟喜好設定視窗
7. 點左邊的"建置並執行", 點上方"Qt Versions"分頁, 點右方"新增"
準備連結qmake
8. 從上面的combo box(下拉式表單)選Macintosh HD
qmake在/usr/local/opt/qt5/bin , 但因usr是隱藏資料夾, 無法點選
9. 按鍵盤之 "Command" + "Shift" + "."
跑出usr等一堆隱藏資料夾
10. 打開/usr/local/opt/qt5/bin/qmake
有了qmake產生makefile檔, 再來就是設定使用的Compiler
11. 點上方"Kits"分頁, 點右方"新增", 下方"Compiler"combo box選"Clang (x86 64bit in /usr/bin)", "Qt版本"選"Qt 5.4.1 (5.4.1)"
至此大功告成, 趕快新增Qt Widgets Application測試. 體驗在Windows和Linux垂涎已久的Macintosh Style
可能有時候還是想在terminal執行qmake, 以下說明PATH變數設定方法
1. vim ~/.bash-profile
不會用vim就用別的文字編輯器吧
2. 加上 export PATH="/usr/local/bin:$PATH" , 儲存檔案
3. 重新開啟terminal, echo $PATH
確定有/usr/local/opt/qt5/bin
現在已可在terminal run qmake
, 可qmake --version
看qt版本
//如果提示:-1: error: Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild.
If you change content of Qt_install_folder/5.7/clang_64/mkspecs/features/mac/default_pre.prf
then it will work only for Desktop kit, not for ex. simulator.
A better way is just to create symlink:
cd /Applications/Xcode.app/Contents/Developer/usr/bin/
sudo ln -s xcodebuild xcrun
so you don't have to change .prf files for all targets.