You are here: Home Documentation Tutorials Building mchelper
Document Actions

Building mchelper

Note: Return to tutorial view.

How to build mchelper (Make Controller Helper) from source.

Installing Qt4

mchelper is built with Trolltech's Qt4, a cross-platform C++ GUI framework.
mchelper is built with Qt4, a cross-platform C++ GUI framework by Trolltech.  Fortunately, for open source projects Qt is provided freely under the GNU GPL. There can be a few snags along the way trying to get this set up on your system, so we'll outline the steps for getting Qt installed properly on your machine.

Qt
Qt4

For all platforms, mchelper currently requires at least Qt 4.3 so you may need to upgrade your installation.

Windows

On Windows, you'll almost certainly want to download the Qt installer that also installs MinGW. Check out the Qt Windows Download Page and grab whatever the latest version is, making sure to get the version that looks like /path/to/qt-win-opensource-4.x.x-mingw.exe. This should get you an installer that will get you all set up with just a double click.

OS X

Download the latest source for Qt on OS X here. Once you've uncompressed the source package, there's the potentially sticky issue of building Qt. It's actually not bad at all, but there are a couple configuration flags to be sure to set when you're building it.

We'll venture into Terminal.app to build Qt. There are just a couple of flags of interest:

  • prefix - where to install Qt. I usually just keep this in /Developer/Qt-4.x.x, although the default location is /usr/local/Trolltech/Qt-4.x.x
  • static - specifies whether Qt is built as static or shared libraries. The default is as shared libraries, which makes for quicker rebuilds and is generally recommended. However, to distribute your final app to people that don't have Qt installed, you'll need to build it statically. Kind of a drag.  If you happen to have two machines, or enough room on your machine, it's worth installing a non-static version for normal development, mainly for the faster compile times.
  • universal - whether to the Qt installation will create Universal Binary code or code for your native platform.
  • sdk - the path to the OS X SDK Qt will use. If you've passed the -universal flag, make sure this SDK is for OS X 10.4 or later.
  • demos & examples - I prefer not to build the demos and examples, so I use the -nomake flag to prevent them from being built.  This, of course, is up to you.

So, a sample configuration for building Qt might look like this:
# cd into the src directory...I keep mine in /Developer/Qt-src-4.x.x
cd /Developer/Qt-src-4.x.x

# now configure the build process, then build it
./configure -prefix /Developer/Qt-4.x.x -universal -sdk /Developer/SDKs/MacOSX10.4u.sdk
-nomake demos -nomake examples
make
sudo make install
This will take quite a while, so make sure you have some other exciting things to do in the meantime. When it's finally finished, you'll want to add the Qt tools to your path. There are plenty of ways to do this, but I just either do it in vi or in another editor like TextMate:
sudo vi /etc/profile
# add /Developer/Qt-4.x.x/bin to your path.
Then you should be in pretty good shape.

Linux/Other

Grab the latest Qt download from http://trolltech.com/developer/downloads/qt/x11 and adapt the instructions above to your system.

Building the code

Set up your desktop environment to work on mchelper.

First, you'll want to grab the source for mchelper. You can do this either by

  • grabbing the latest code or a tag from the SVN repository, or
  • downloading a .zip archive of the source for the last release.


To checkout a copy of the latest source via SVN, you'll issue a command like

svn co https://makingthings.svn.sourceforge.net/svnroot/makingthings/mchelper/trunk

As with most projects, development is done in the trunk and release snapshots are kept in tags.  The trunk will always be the most up to date, but that can mean that there might be a bug or two...

Browse the .zip mchelper downloads on the Make Controller SourceForge page here.

Windows

I've used Eclipse as an IDE for Qt apps and it's worked quite nicely. There's a little bit of monkeying involved to set it up, however, so be prepared.

To add...
  • setting up the workspace
  • adding qmake as an external tool

OS X

Trolltech has made it extra easy to work with Qt apps on OS X by providing a simple way to generate Xcode projects for a group of files. This is what I've done, and it's worked great. To do this, in the Terminal:
# head to wherever you downloaded the mchelper source to
cd /path/to/mchelper/source

# build the Xcode project
qmake -spec macx-xcode mchelper.pro

Because mchelper on OS X uses the Sparkle auto-update framework, there are a few extra steps:

  • drag Sparkle.framework from resources/osx/Sparkle-1.1 to the Frameworks group in your Xcode project
  • add a new "copy files" build phase to copy Sparkle into mchelper.  To do this, right-click on mchelper in the Targets groups and select "new build phase", and then "copy files build phase".  Select Frameworks as the destination, and then drag Sparkle.framework from within the Xcode project into mchelper's new build phase.
  • enable the carbon_cocoa.m file in the source group by clicking in the empty little box all the way on the right, and right-click on McHelperWindow.cpp and select Get Info.  In the Filetype dropdown, select sourcecode.cpp.objcpp.  This allows Qt's Carbon-based code to link with Sparkle's Cocoa-based code.

 

Note that any time you add files to the project, you'll need to also add them to the project file mchelper.pro and regenerate the Xcode project (yes, this is a drag).

Linux/Other

KDevelop is a pretty popular IDE for Qt projects, but I haven't used it too much.  If anybody has any specific recommendations, please let me know...