开发者

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

I'm trying to install QtROOT, and as part of the installation (spe开发者_如何转开发cifically, 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


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.


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).


I need to install LiteIDE on my mac and in the install guide, the QTDIR is necessary. I install the qt with the homebrew by brew install qt --build-from-source, it takes about 2 hours in RMBP. After the install finished, there is still no QTDIR path. By checking the build_osx.sh, i know it's just the parent folder of bin. so i set the path by export QTDIR=/usr/local/Cellar/qt/4.8.6. Then run the ./build_osx.sh again. it works.

Hope this will be helpful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜