QtD on Mac OS X Case Study

This is a description of how I got QtD working on a Mac.

Though I'm sure that there is a way to do it, I was not able to use a Qt installed using frameworks. The significance of this is that

  1. the binary QtCreator SDK installs using frameworks, so you can't use its Qt
  2. not using frameworks means that you can't use Cocoa-Qt or 64-bit Qt
  3. so, we must use 32-bit Carbon-Qt

So, I had to download the Qt source and build a no-frameworks version.

Environment

  • system: Mac OS X 10.5.8
  • kernel: Darwin 9.8.0

gcc (from XCode 3.1.3)

$ which gcc
/usr/bin/gcc

$ gcc -v
Using built-in specs.
Target: i686-apple-darwin9
Configured with: /var/tmp/gcc/gcc-5493~1/src/configure 
--disable-checking 
-enable-werror 
--prefix=/usr 
--mandir=/share/man 
--enable-languages=c,objc,c++,obj-c++ 
--program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ 
--with-gxx-include-dir=/include/c++/4.0.0 
--with-slibdir=/usr/lib 
--build=i686-apple-darwin9 
--with-arch=apple 
--with-tune=generic 
--host=i686-apple-darwin9 
--target=i686-apple-darwin9
Thread model: posix
gcc version 4.0.1 (Apple Inc. build 5493)

cmake (from the fink packages)

$ which cmake
/sw/bin/cmake

$ cmake --help
cmake version 2.6-patch 4

D compiler (from Digital Mars (D2 with Phobos))

$ which dmd
/Users/jra/usr/dmd2/osx/bin/dmd

$ dmd
Digital Mars D Compiler v2.031
Copyright (c) 1999-2009 by Digital Mars written by Walter Bright
Documentation: http://www.digitalmars.com/d/2.0/index.html

Qt

downloaded this:

http://get.qt.nokia.com/qt/source/qt-mac-opensource-src-4.5.2.tar.gz

which is linked to on this page:

http://qt.nokia.com/downloads/mac-os-cpp

configured like this (cd'd to parallel directory for out-of-source build):

../qt/configure \
-no-qt3support \
-platform macx-g++ \
-no-framework \
-arch x86 \
-sdk

make and install it, add to PATH

$ which qmake
/usr/local/Trolltech/Qt-4.5.2/bin/qmake

$ qmake -query
QT_INSTALL_PREFIX:/usr/local/Trolltech/Qt-4.5.2
QT_INSTALL_DATA:/usr/local/Trolltech/Qt-4.5.2
QT_INSTALL_DOCS:/usr/local/Trolltech/Qt-4.5.2/doc
QT_INSTALL_HEADERS:/usr/local/Trolltech/Qt-4.5.2/include
QT_INSTALL_LIBS:/usr/local/Trolltech/Qt-4.5.2/lib
QT_INSTALL_BINS:/usr/local/Trolltech/Qt-4.5.2/bin
QT_INSTALL_PLUGINS:/usr/local/Trolltech/Qt-4.5.2/plugins
QT_INSTALL_TRANSLATIONS:/usr/local/Trolltech/Qt-4.5.2/translations
QT_INSTALL_CONFIGURATION:/Library/Preferences/Qt
QT_INSTALL_EXAMPLES:/usr/local/Trolltech/Qt-4.5.2/examples
QT_INSTALL_DEMOS:/usr/local/Trolltech/Qt-4.5.2/demos
QMAKE_MKSPECS:/usr/local/Trolltech/Qt-4.5.2/mkspecs
QMAKE_VERSION:2.01a
QT_VERSION:4.5.2

QtD (from svn repository)

$ svn info
Path: .
URL: http://svn.dsource.org/projects/qtd/trunk
Repository Root: http://svn.dsource.org/projects/qtd
Repository UUID: 1c76f9a9-97a6-433d-956c-bb6a2077f4c7
Revision: 272
Node Kind: directory
Schedule: normal
Last Changed Author: maxter
Last Changed Rev: 272
Last Changed Date: 2009-08-31 02:07:28 -1000 (Mon, 31 Aug 2009)

Make sure correct versions of dmd, qmake, and cmake are in your path (use which to check)

build QtD as described in build instructions for Linux from wiki (cmake using defaults)

Build examples/tutorials/tutorial/t1

edit build.sh like this:

#! /bin/bash

dmd main.d \
-I../../../../ \
-I../../../../qt/d2 \
-I../../../../bld/build/ \
-I../../../../bld/build/qt \
-I../../../../bld/build/include \
-L-L../../../../lib \
-L-L../../../../bld/build/lib \
-L-L/usr/local/Trolltech/Qt-4.5.2/lib \
-L-lqtdgui \
-L-lqtdcore \
-L-lQtCore \
-L-lQtGui \
-L-lstdc++ \
-oft1

build t1 using build.sh

then run ./t1

It worked for me; good luck!