简体   繁体   English

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

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

I want to install Qt on my Mac and use the qmake through terminal to compile code. 我想在我的Mac上安装Qt并使用qmake through终端来编译代码。 I downloaded the open source Qt Creator from Qt site, but I cannot set it up. 我从Qt网站下载了开源Qt Creator,但我无法进行设置。 Anyone with similar problems? 有类似问题的人?
System: Mac OS X Sierra, Qt version: 5.7. 系统:Mac OS X Sierra,Qt版本:5.7。 I'm downloading the open source installer from qt.io/download-open-source . 我正在从qt.io/download-open-source下载开源安装程序。 I'm installing it to Users/MyUserAccount and i want set it up so i can compile C++ code with qmake && make 我正在将它安装到Users / MyUserAccount,我想要设置它,这样我就可以使用qmake && make编译C ++代码

Just to provide another solution using Homebrew. 只是为了使用Homebrew提供另一种解决方案。

As you've found QT4 isn't compatible with Mac OSX Sierra. 您发现QT4与Mac OSX Sierra不兼容。

You can install QT5 using: 您可以使用以下命令安装QT5:

brew install qt5

But you'll find you can't access qmake from the command line. 但是你会发现你无法从命令行访问qmake。 To rectify this you'll need to run: 要纠正这个问题,你需要运行:

brew link qt5 --force

If you want to run qmake from command line, add the directory where qmake is located to PATH environment variable. 如果要从命令行运行qmake ,请将qmake所在的目录添加到PATH环境变量。 How to do it depends on the shell you are using, for bash it is done by adding export PATH=$PATH:<path_to_qmake> to either ~/.profile , ~/.bash_profile or ~/.bashrc . 如何做到这取决于你正在使用的shell,对于bash,它是通过将~/.profile~/.bash_profile~/.bashrc export PATH=$PATH:<path_to_qmake>添加来完成的。

For Installing QT4:- https://github.com/cartr/homebrew-qt4 对于安装QT4: - https://github.com/cartr/homebrew-qt4

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

For Installing QT5:- 安装QT5: -

brew install qt5 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM