This is an old revision of the document!
Table of Contents
CompilingOnMac
This explains how to compile libhimd and QHiMDTransfer on MacOS 10.4 or higher.
Prerequisites
First, download and install Apple XCode for your version of MacOS
The latest XCode (3.2.5) can be obtained from http://developer.apple.com, while older versions (2.5, 3.1.4) can be found at http://connect.apple.com.
- for MacOS 10.4 the latest version is 2.5: xcode25_8m2558_developerdvd.dmg
- for MacOS 10.5 the latest version is 3.1.4: xcode314_2809_developerdvd.dmg
- for MacOS 10.6 the latest (free) version is 3.2.6: xcode_3.2.6_and_ios_sdk_4.3_final.dmg
- for MacOS 10.7 the latest version is 4.2 and can be downloaded through the Mac App Store
If you're using MacOS 10.6, you can also buy XCode (4.x) in the Mac App Store (free for 10.7).
Then, download and install the Qt development libraries and headers for your version of MacOS
http://qt.nokia.com/downloads/qt-for-open-source-cpp-development-on-mac-os-x
- On Intel machines, you can simply download the pre-compiled libraries plus the build and interface tools. These are sufficient to build QHiMDTransfer.
- On PPC machines and earlier version of MacOS, you can either download the last pre-compiled version, 4.6.4: ftp://ftp.trolltech.com/qt/source/qt-mac-cocoa-opensource-4.6.4.dmg or build and install the latest Qt version through Macports (see below).
Installing Macports
The last prerequisite is to download and install Macports.
After installing macports, make sure that you can run the port command. To test this, open a terminal (Applications→Utilities→Terminal) and type port. If you get a "command not found" error, "/opt/local/bin" has to be added to your path by adding the file macports in your paths.d folder, in the same terminal, as normal user, type:
sudo echo "/opt/local/bin" > /etc/paths.d/macports
Installing extra packages in Macports
In the same terminal, type:
sudo port install glib2 libmad git-core sox libgcrypt taglib libid3tag libusb-devel
You will need to type your password to authenticate the sudo. Please be aware, that the port command will take quite an amount of time when you run it the first time since MacPorts has to compile all necessary packages from source. Especially on older PowerPC machines, the compilation of the code can take several hours (around 5 hours on a Mac Mini G4). It's highly recommended to let this step run over night on older machines.
Building and installing Qt4 through Macports
To install Qt4 through Macports, type:
sudo port install qt4-mac
NOTE: qt4-mac is a very large package and takes hours to compile. Be prepared to have your computer compile for at least 12~24 hours. Not recommended on machines below 1 GHz. Please consider installing the pre-compiled Qt 4.6.4 binaries in this case (see above). Alternatively, you can cross-compile for PPC on an i386 host (see below).
Getting the code
After the additional ports have been installed in Macports, you'll to fetch the source code from our server.
Building and Running
There are in principal two different toolchains which can be used to build libhimd and qhimdtransfer on MacOS. One is using the standard Unix make command and the other one involves Apple's special XCode system. The former is recommended as the XCode variant might fail to build on MacOS X 10.6 (Snow Leopard) or on PPC machines.
Using make
This variant is very similar to the way the software is build on Linux. It just takes calling qmake with special options and then the obligatory make:
qmake -spec macx-g++ -r make make install
The executable will be called "QHiMDTransfer.app" and can be found in the sub-folder qhimdtransfer. make install is used on MacOS X only to install the translations into the app bundle in the source tree. You don't need administrator access for make install.
Using XCode
This method is not recommended as it might cause trouble on MacOS 10.6 (Snow Leopard) with so-called Jam targets. Also, you might run into trouble when qmake creates project files for MacOS/i386 on a PPC machine.
cd linux-minidisc qmake -r
First, build libhimd:
cd libhimd xcodebuild cd ..
Then QHiMDTransfer:
cd qhimdtransfer xcodebuild cd ..
To run QHiMDTransfer, open the source directory in the finder, then change to qhimdtransfer/build/Default to locate the application "QHiMDTransfer" and double-click it to start.
Generating translation files
To generate the translation files for qhimdtransfer to display the GUI in your native language (if available for your language), call lrelease:
cd qhimdtransfer make ts
Deploying the .app file
The final step of creating the Qt application is the deployment which makes it independent of the build environment (Qt, Macports, XCode) by incorporating all dynamic libraries into the app package. Since Qt provides a command-line utility to perform this step, this involves nothing but invoking it:
cd qhimdtransfer macdeployqt QHiMDTransfer.app
Creating the installer .dmg image
Please see this website for instructions: http://www.ploem.be/blog/?page_id=26
Building Universal Binaries
To build universal binaries (PPC + i386) or (i386 + x86_64), Macports ports need to be build with the +universal flag enabled, thus
sudo port install glib2 libmad git-core sox libmcrypt taglib +universal
See: https://trac.macports.org/wiki/howto/buildUniversal
Then add the additional architecture for the Qt project file, see:
http://doc.qt.nokia.com/4.7/qmake-platform-notes.html#creating-universal-binaries
meaning, adding either of
CONFIG+=x86 x86_x64 ppc
to the project files.
Cross-compiling for PPC on i386 (on MacOS 10.5)
It is possible to cross-compile Macports and the MiniDisc software for PPC on an i386 host. This is very convenient as it dramatically speeds up building the software for PPC since the fastest PPC Macs are much slower than current Intel machines.
First, install XCode and Macports as described above, but do not install Qt as it will be installed through Macports.
After installing Macports, edit the macports.conf (in /opt/local/etc/macports) configuration file to set the build rchitecture to PPC:
build_arch ppc
Then, edit the portfile for libffi to fix a problem with cross-compilation. Type "port edit libffi" and add:
configure.args --build=powerpc-apple-darwin9.8.0 --with-gcc-arch=ppc
Other ports to be patched: libmad, orc.
For orc, comment the first line shown here out (prepend the hash sign) and add the second one:
#configure.optflags-append -Xarch_i386 -O1 configure.args --build=powerpc-apple-darwin9.8.0
For libmad and fftw-3, just add:
configure.args --build=powerpc-apple-darwin9.8.0
For fftw-3, comment out all lines containing references to "sse2".
Finally, for xorg-libXrandr, add:
configure.ldflags -headerpad_max_install_names
Now, install the dependencies as usual, but include qt4-mac:
sudo port install glib2 libmad git-core sox libgcrypt taglib libid3tag libusb-devel qt4-mac
Finally, edit the qmake project file of linux-minidisc, md.pro by adding the following two lines:
CONFIG += ppc CONFIG -= i386
Then, build as described above.
Important Notes
- The application runs only on MacOS versions equal or higher than version of the build system
- There is a bug in qmake which produces broken Makefiles or xcode project files on PowerPC Macs in Qt 4.5.3 and higher; please replace "i386" with "ppc" in all Makefiles in the qhimdtransfer folder to be able to build on PPC Macs, see http://bugreports.qt.nokia.com/browse/QTBUG-6150 (This bug will be fixed for Qt SDK 4.7.4)
- The current portfile for ffmpeg in Macports is broken. Please use port edit ffmpeg to add the configure option "–extra-ldflags=-headerpad_max_install_names", see: https://trac.macports.org/ticket/23372
Links
- http://doc.trolltech.com/4.5/deployment-mac.html - Trolltech: Deploying an Application on Mac OS X