User Tools

Site Tools


compilingonmac

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
compilingonmac [2012/10/10 00:19]
glaubitz
compilingonmac [2017/10/01 11:04] (current)
thp
Line 1: Line 1:
 ====== CompilingOnMac ====== ====== CompilingOnMac ======
  
-This explains how to compile libhimd ​and QHiMDTransfer on MacOS 10.4 or higher.+To install the build dependencies,​ use XCode and HomebrewThere is a script for installing the dependencies:​
  
-===== Prerequisites =====+https://​github.com/​glaubitz/​linux-minidisc/​blob/​master/​build/​install_dependencies.sh
  
-==== Firstdownload and install Apple XCode for your version of MacOS ====+At the momentthe build dependencies can be installed with:
  
-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]].+        brew update 
 +        brew install --force qt5 mad libid3tag libtag glib libusb libusb-compat libgcrypt 
 +        brew link --force qt5
  
-  * 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/10.8 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/10.8). 
- 
-==== 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. 
- 
-[[http://​www.macports.org]] 
- 
-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: 
- 
-<​code>​ 
-sudo echo "/​opt/​local/​bin"​ > /​etc/​paths.d/​macports 
-</​code>​ 
- 
-===== Installing extra packages in Macports ===== 
- 
-In the same terminal, type: 
- 
-<​code>​ 
-sudo port install glib2 libmad git-core sox libgcrypt taglib libid3tag libusb 
-</​code>​ 
- 
-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 (measured 3 hours on a PowerMac G4 with 867 MHz and 1GB RAM). 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: 
- 
-<​code>​ 
-sudo port install qt4-mac 
-</​code>​ 
- 
-**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 [[start#​source_code|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//: 
- 
-<​code>​ 
-qmake -spec macx-g++ -r 
-make 
-make install 
-</​code>​ 
- 
-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. 
- 
-<​code>​ 
-cd linux-minidisc 
-qmake -r 
-</​code>​ 
- 
-First, build libhimd: 
- 
-<​code>​ 
-cd libhimd 
-xcodebuild 
-cd .. 
-</​code>​ 
- 
-Then QHiMDTransfer:​ 
- 
-<​code>​ 
-cd qhimdtransfer 
-xcodebuild 
-cd .. 
-</​code>​ 
- 
-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: 
- 
-<​code>​ 
-cd qhimdtransfer 
-make ts 
-</​code>​ 
-==== 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: 
- 
-<​code>​ 
-cd qhimdtransfer 
-macdeployqt QHiMDTransfer.app 
-</​code>​ 
- 
-==== 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 
- 
-<​code>​ 
-sudo port install glib2 libmad git-core sox libmcrypt taglib +universal 
-</​code>​ 
- 
-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 
- 
-<​code>​ 
-CONFIG+=x86 x86_x64 ppc 
-</​code>​ 
- 
-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: 
- 
-<​code>​ 
-build_arch ​                     ppc 
-</​code>​ 
- 
-Then, edit the portfile for libffi to fix a problem with cross-compilation. Type "port edit libffi"​ and add: 
- 
-<​code>​ 
-configure.args --build=powerpc-apple-darwin9.8.0 --with-gcc-arch=ppc 
-</​code>​ 
- 
-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: 
- 
-<​code>​ 
-#​configure.optflags-append -Xarch_i386 -O1 
-configure.args --build=powerpc-apple-darwin9.8.0 
-</​code>​ 
- 
-For //libmad// and //fftw-3//, just add: 
- 
-<​code>​ 
-configure.args --build=powerpc-apple-darwin9.8.0 
-</​code>​ 
- 
-For //fftw-3//, comment out all lines containing references to "​sse2"​. 
- 
-Finally, for //​xorg-libXrandr//,​ add: 
- 
-<​code>​ 
-configure.ldflags -Wl,​-headerpad_max_install_names 
-</​code>​ 
- 
-Now, install the dependencies as usual, but include //​qt4-mac//:​ 
- 
-<​code>​ 
-sudo port install glib2 libmad git-core sox libgcrypt taglib libid3tag libusb-devel qt4-mac 
-</​code>​ 
- 
-Finally, edit the qmake project file of linux-minidisc,​ //md.pro// by adding the following two lines: 
- 
-<​code>​ 
-CONFIG += ppc 
-CONFIG -= i386 
-</​code>​ 
- 
-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 //​Makefile//​s or xcode project files on PowerPC Macs in Qt 4.5.3 and higher; please replace "​i386"​ with "​ppc"​ in all //​Makefile//​s 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 
compilingonmac.txt · Last modified: 2017/10/01 11:04 by thp