LPub4 is the best (and almost only) tool for generating building instructions for LEGO models. Developed over the years by Kevin Clague it has been used to generate the building instructions for numerous books. I use it for all of my own work.
This tutorial will show you how to build the latest release of LPub4 for Mac OS using the native Mac developer tool: XCode. I have tested this using Mac OS 10.6.5 on an older spec MacBook Pro.
Download the latest Qt libraries
Qt is an open-source toolkit used for cross-platform graphics programming. It is ideal for building GUI applications such as LPub4. Before you can build LPub4 you will need the latest version of the Qt libraries installed on your Mac.
As of this writing the latest release is Qt 4.7.1. You can find more up-to-date versions at:http://qt.nokia.com/downloads. Be sure to select the LGPL option for downloading. You will be presented with a set of download options, much like the following screenshot. Select the Qt libraries 4.7.1 for Mac from the list on the right-hand side.
Once you have completed the download launch the Qt installer and follow through the standard installation steps for any piece of Mac software. The Qt libraries are installed in/usr/local/Qt4.7/
Get the latest LPub4 source
The source code for LPub4 is available in SourceForge. You can check out the latest code using cvs:
Start Terminal, and then enter:
cvs -d:pserver:firstname.lastname@example.org:/cvsroot/lpub4 login
which will log you into the CVS repository at sourceforge with anonymous access. Just press Enter when prompted for a password.
Next, download the latest LPub4 source tree:
cvs -z3 -d:pserver:email@example.com:/cvsroot/lpub4 co -P LPub4
you will see the source code being downloaded in your Terminal window, and it will end up in a folder named LPub4.
Before you begin you will need a copy of Xcode, Apple’s development IDE for Mac OS. A copy of Xcode is located on your Mac OS install DVD. Insert the DVD and navigate to the XcodeTools package, double-click on it to launch the installer. Alternatively you can download XCode from the Mac developer website:http://developer.apple.com/technologies/tools/xcode.html.
Create the XCode Makefile
The next step is to create a Makefile for building LPub4 that is tailored to XCode builds. Change to the LPub4 directory where you copied the source code in Terminal. Enter the following command to create an XCode Makefile:
/usr/bin/qmake -spec /usr/local/Qt4.7/mkspecs/macx-xcode -macx -o Makefile LPub.pro
Not much seems to have happened (in the way of all good Unix tools 🙂 but if you look in the LPub4 folder you will see that a new XCode project has been created:
Build LPub4 using XCode
Wow, all this work and we still haven’t even built the code yet! Well don’t worry, we can now get to work and run XCode to do the build. Double click on the Makefile.xcodeproj in your Finder to launch XCode 3:
By default XCode selects a debug build. Click on the pull-down menu highlighted above to select a release build. Then double-click on the Makefile in the “Groups & Files” panel to edit the Makefile properties. A window will open as shown below.
By default the Makefile generated includes targets for older PowerPC (ppc) architectures. On my i386 Mac running Mac OS 10.6 I discovered that the linker step would fail if these targets remained in the Makefile. So we can edit them out by double-clicking on the Valid Architectures line and in the dialog box select remove all the architectures except i386 and x86_64.
Select the ppc, ppc54, ppc7400 and ppc970 lines and click on the – button. Then click ok. Close the Makefile Info window.
And now (drum roll) we can build LPub4! Click on the “Build and Run” button and the build should commence:
All going well the build should complete and then Lpub4 will open and run from within XCode. Test it out to make sure everything works ok, and then you can quit XCode.
The LPub application will be saved in the LPub4 folder that contains the Makefile.xcodeproj we created earlier.
Create an application bundle
Now we have the LPub.app application built there is one final step. We would like to be able to distribute the LPub application as an application-bundle. In the Mac world an application bundle contains everything the application needs to run; you can drag it into your Applications folder and when you are done with it you drag it to the Trash.
Luckily the good folks at Qt have created a script to automate building a Mac application bundle using Qt libraries. And they have sensibly named it macdeployqt. To use it simply open the Terminal in the directory contain the LPub.app and run
/usr/bin/macdeployqt Lpub.app -dmg
The -dmg option creates a disk-image to contain the final application in.
And here is one I prepared earlier: a compiled version of LPub.dmg version 18.104.22.168 for Mac OS 10.6!