Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On OS X, what is the proper setting for $QTDIR?

Tags:

macos

root

qt

I'm trying to install QtROOT, and as part of the installation (specifically, the readme file in the QtROOT tarball at http://root.bnl.gov/QtRoot/downloads/qtFullRoot.tar.gz), it mentions to make sure that QTDIR is set. I've installed from the Qt 4.6.3 SDK installation for Mac OS X, and I have no such environment variable set. I've tried googling to figure out where it should be set to, but the options I've found (such as /usr/local/qt) don't exist. What should this variable be set to?

OS X 10.6.4, Qt 4.6.3, ROOT 5.26/00, QtROOT... I have no idea. :P

Thanks,

Paul

like image 818
TraxusIV Avatar asked Jan 21 '23 16:01

TraxusIV


1 Answers

Qt's packaged installer for OSX scatters things throughout the /Developer and /Library directories rather than installing to a self-contained location in /usr/local or /opt/local as you might expect it to do on other unix-based systems.

Incidentally, Qt follows Apple's way of doing things in this respect, so it's really not wrong -- it's just different -- but it does make some 3rd party Qt applications somewhat difficult to build on OSX.

The packaged Qt installer itself has the following to say on this topic:

After a successful install, you can find most new things in /Developer. Specifically things will be located in the following places:

  • Qt Designer, Qt Linguist: /Developer/Applications/Qt
  • Qt Documentation: /Developer/Documentation/Qt
  • Qt Examples: /Developer/Examples/Qt
  • Qt Plugins: /Developer/Applications/Qt/Plugins
  • Qt Frameworks: /Library/Frameworks
  • Qt Libraries: /usr/lib
  • qmake, moc, uic, etc.: /Developer/Tools/Qt (symlink to /usr/bin)
  • Uninstall script: /Developer/Tools/uninstall-qt.py

So, it does put the libs into '/usr/lib', and it symlinks the essential Qt tools (like qmake) into '/usr/bin'. This suggests that QTDIR could be set to '/usr'. In practice however, this doesn't work because the qt headers remain buried in '/Library/Frameworks/Qt*/Headers/*.h', while builds that rely on $QTDIR will end up looking for the qt headers in "${QTDIR}/include/" instead.

The easiest way around all this is to build Qt from source. The install location will default to something like /usr/local/Trolltech/Qt-4.6.3 (note the version number, and adjust accordingly). You can override the default install location by using the -prefix option on ./configure.

A simpler approach is to let macports build it for you. This is the approach I ended up taking (and with good success). Just install macports, if you don't already have it. Then:

> sudo port selfupdate
> sudo port install qt4-mac

Macports will work its magic, and when it's done Qt will be installed, in its entirety, at /opt/local/libexec/qt4-mac.

Regardless of how you build Qt, expect a full build to take several hours. It's a very large code base.

like image 93
Lee Avatar answered Jan 25 '23 15:01

Lee