17

Coming from Ubuntu I bought a new iMac and tried to setup my Qt development. Everything else is already up and running. Xcode command line tools are also installed.

Because it surprised me how good brewand brew caskworked I wanted to install Qt5with them. On the one side it is very fast and I do not have to got to any homepage in order to download it. On the other side I do not have to care about the installation directory. Having multiple version installed should also be a lot simpler though.

I used the following commands:

brew install qt5

brew cask install qt-creator

Qt5 is now installed under /usr/local/Cellar/qt5/5.4.1. I also added the bin folder to my path (done in .bash_profile). QtCreator, Linguist and all the other applications are shown in my launchpad. But unfortunately, it is still not done.

QtCreator says that no version of Qt is known. I tried to add qmake but I was not able to navigate to the folder mentioned above.

Could anybody give me a hint on how to fix this issue? Installing qt via installer should be the last option.

Nick Lehmann
  • 598
  • 1
  • 7
  • 25

4 Answers4

11

I had similar issue with Qt Creator, now on Mac GUI applications do not have access to environmental variables (in previous versions it was different).

You need to setup path to qmake in Qt Creator manually using Command-Shift-G in Finder to navigate to Folder you need.

demonplus
  • 5,613
  • 12
  • 49
  • 68
  • 4
    Mac applications [do have access to environment variables](http://stackoverflow.com/a/588442/2167797). Just run `launchctl setenv QTDIR /usr/local/Cellar/qt5/5.4.1` See the link on how to set this permanently. – Linville Apr 29 '15 at 19:25
  • It was so in old versions of Mac OS but according to discussions here http://stackoverflow.com/questions/25385934/setting-environment-variables-via-launchd-conf-no-longer-works-in-os-x-yosemite?lq=1 this method is working in some versions of Yosemite but not working in others (10.10.0 and 10.10.1 due to bug) – demonplus Apr 30 '15 at 06:23
  • This [bug](http://stackoverflow.com/questions/25385934/setting-environment-variables-via-launchd-conf-no-longer-works-in-os-x-yosemite?lq=1#comment43575294_25912736)? It only affects the PATH variable. The [LaunchAgents](http://stackoverflow.com/a/26586170/2167797) method seems to set it permanently seems to work fine for Yosemite. – Linville Apr 30 '15 at 13:16
  • @Linville Based on the link you shared - I used this to point to new version of Qt(5.5,which I manually moved to /usr/local/Cellar/qt5/location instead of 4.8.7) . Did the following -: (added to environment.plist) launchctl setenv QTDIR /usr/local/Cellar/qt5/5.5 and then launchctl load ~/Library/LaunchAgents/environment.plist . On doing qmake --version now, I still see QMake version 2.01a Using Qt version 4.8.7 in /usr/local/Cellar/qt/4.8.7/lib - what am I doing wrong ? I am on yosemite 10.10.5. – ekta Feb 24 '16 at 06:35
7

Another option is to use brew link qt5 --force, which will symlink the various Qt5 binaries and libraries into your /usr/local/bin and /usr/local/lib directories. This will give you qmake at the command line, without requiring you to add anything special to your path in .bash_profile. The main reason this isn't done by default is that Qt4 is also somewhat popular.

It could get a little messy, but if you need to install Qt4 as well, you can unlink Qt5 at any time, by doing brew unlink qt5, and it will keep the installation intact. Then do brew install qt to get Qt4, which unlike the brew installation for Qt5 will indeed create the links directly into /usr/local without you having to manually do brew link qt. You can unlink Qt4 and relink Qt5 (or vice-versa) whenever you need to switch.

nonrectangular
  • 2,080
  • 20
  • 9
0

In my cases I needed to set it in Preferences => QT Versions => Add. Environment variables also did not help. Small popup when starting app also did not work.

enter image description here

Evalds Urtans
  • 6,436
  • 1
  • 41
  • 31
0

I use command like this:

brew install qt@5

and. success install qt5 by brew.

Doongbin
  • 13
  • 3
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 15 '22 at 20:46