简体   繁体   English

如何使用自制软件在 macOS 上安装 qt4?

[英]How to Install qt4 on macOS with homebrew?

I need to install the qt4 C++ framework for one of my classes.我需要为我的一个类安装 qt4 C++ 框架。 I tried using the regular installer from the download archives page for both qt4.7 and qt4.8, however I get the warning:我尝试使用 qt4.7 和 qt4.8 的下载档案页面中的常规安装程序,但是我收到警告:

"Installing this package may damage your system, and the installation may fail."

So I looked into installing it via homebrew and initially tried:所以我考虑通过自制软件安装它并最初尝试:

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

However, that gives me this error:但是,这给了我这个错误:

Error: Calling brew tap-pin user/tap is disabled! Use fully-scoped user/tap/formula naming instead.

I looked online for a solution and was able to install it by omitting the brew tap-pin cartr/qt4 command:我在网上寻找解决方案,并且能够通过省略brew tap-pin cartr/qt4命令来安装它:

brew tap cartr/qt4
brew install qt@4

I then tried to create a sample qt program in the CLion IDE and checked the version I was using, and it said I was using qt5 (from the python anaconda distribution).然后我尝试在 CLion IDE 中创建一个示例 qt 程序并检查我使用的版本,它说我使用的是 qt5(来自 python anaconda 发行版)。 So my question is, can I install both qt4 and qt5 on my system simultaneously?所以我的问题是,我可以同时在我的系统上安装 qt4 和 qt5 吗? How do I select which version to use?如何选择要使用的版本?

You can install both simultaneously.您可以同时安装两者。 You can select which to use.您可以选择使用哪个。

When you install qt (meaning qt5) using homebrew , it produces a "Caveats" message that answers your question.当您使用homebrew安装qt (意思是 qt5)时,它会生成一条“警告”消息来回答您的问题。

  • It says will need to set certain environment variables yourself.它说需要自己设置某些环境变量。
  • It says that, in only those shell sessions where you set those environment variables, qt (meaning qt5) will be available.它说,只有在您设置这些环境变量的那些 shell 会话中, qt (意思是 qt5)才可用。
  • It says, if you want qt always available, then you can simply put those settings in your dot files.它说,如果您希望qt始终可用,那么您可以简单地将这些设置放在您的点文件中。

If you install qt@4 and set those same variables to point to qt@4 , then qt@4 will be available instead.如果您安装qt@4并将这些相同的变量设置为指向qt@4 ,那么qt@4将可用。

You can view the same "Caveats" message again using brew info qt .您可以使用brew info qt再次查看相同的“注意事项”消息。 Here is the whole message:这是整个消息:

qt is keg-only, which means it was not symlinked into /usr/local,
because Qt 5 has CMake issues when linked.

If you need to have qt first in your PATH run:
  echo 'export PATH="/usr/local/opt/qt/bin:$PATH"' >> ~/.zshrc

For compilers to find qt you may need to set:
  export LDFLAGS="-L/usr/local/opt/qt/lib"
  export CPPFLAGS="-I/usr/local/opt/qt/include"

For pkg-config to find qt you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/qt/lib/pkgconfig"

The same commands with qt@4 made qt@4 available for me:qt@4相同的命令使qt@4对我可用:

export PATH="/usr/local/opt/qt@4/bin:$PATH"

export LDFLAGS="-L/usr/local/opt/qt@4/lib"
export CPPFLAGS="-I/usr/local/opt/qt@4/include"

export PKG_CONFIG_PATH="/usr/local/opt/qt@4/lib/pkgconfig"

By the way, I installed qt@4 using the user/tap/formula syntax: brew install cartr/qt4/qt@4顺便说一句,我使用 user/tap/formula 语法安装了qt@4brew install cartr/qt4/qt@4

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

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