如何在MacOS X Sierra上安装Qt并在终端上添加qmake

How to install Qt on MacOS X Sierra and add qmake on terminal

本文关键字:终端 添加 qmake Qt 安装 MacOS Sierra      更新时间:2023-10-16

我想在我的Mac上安装Qt,并使用qmake通过终端编译代码。我从Qt网站下载了开源Qt Creator,但我无法设置它。有人有类似的问题吗?
系统:Mac OS X Sierra,Qt版本:5.7。我正在从qt.io/download-开源下载开源安装程序。我正在安装它到用户/MyUserAccount,我想设置它,所以我可以编译c++代码与qmake &&使

只是提供另一种使用Homebrew的解决方案。

因为你已经发现QT4不兼容Mac OSX Sierra。

你可以安装QT5使用:

brew install qt5

但是你会发现你不能从命令行访问qmake。要纠正这个错误,您需要运行:

brew link qt5 --force

如果要从命令行运行qmake,需要在PATH环境变量中添加qmake所在目录。如何做到这一点取决于您正在使用的shell,对于bash,可以通过将export PATH=$PATH:<path_to_qmake>添加到~/.profile, ~/.bash_profile~/.bashrc来完成。

安装QT4:-https://github.com/cartr/homebrew-qt4

brew tap cartr/qt4
brew tap-pin cartr/qt4
brew install qt@4

安装QT5:-

brew install qt5