tags:

views:

78

answers:

2

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

A: 

I didn't install Qt from the installer (but compiled it myself), so I don't know the default location.

However, where you installed Qt, there is your QTDIR. Search for qmake, it should reside in some bin/ folder. one up is QTDIR ($QTDIR/bin/qmake). Usually it's not necessary anymore to set QTDIR these days to build a Qt project, just qmake must be in the PATH, everything else found then. But some projects might require it though (if they use a custom build system that still uses QTDIR).

Frank
well, if that's the case, then that would be /usr. does that seem right?
TraxusIV
just as some additional info, QtROOT seems to be determined to buck the trend. It no only requires QTDIR to be set, but the install script will install it in the same directory where you build the QtROOT package. Not in /usr/local/Trolltech/ where you would expect to find it. <shrug>
TraxusIV
you have qmake in /usr/bin? wow, that sounds weird (who wants to have Qt mess with the system /usr?). Or /usr/local/Trolltech/.../bin/qmake, as your last comment suggests? Then /usr/local/Trolltech/... is your QTDIR. ("..." == any other directories in between).
Frank
+1  A: 

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.

Lee
A truly excellent answer. I figured most of it out already the hard way, but excellent nevertheless. Coincidentally, the full build on my 2005-6 era MBP is around 12 hours or so (I've had to do it three or four times now, go figure).
TraxusIV