Cross-Development on Mac
Sponsored Links
This presentation is the property of its rightful owner.
1 / 19

May, 2006 PowerPoint PPT Presentation

  • Uploaded on
  • Presentation posted in: General

Cross-Development on Mac. May, 2006. Andr é Krützfeldt. Tokyo Jamboree #8. Macintosh and Xcode. OS X does come with Xcode bundled Newest version at: Includes all gnu compilers (4.0.1) and utilities Download is about 900MB

Download Presentation

May, 2006

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

May 2006

Cross-Development on Mac

May, 2006

André Krützfeldt

Tokyo Jamboree #8

Macintosh and xcode

Macintosh and Xcode

  • OS X does come with Xcode bundled

  • Newest version at:


  • Includes all gnu compilers (4.0.1) and utilities

  • Download is about 900MB

  • Good for Apple development

    • you will need it

  • For embedded systems, not applicable

Complete your mac tools

Complete your Mac tools

  • Make your development complete!

  • Use fink


  • It installs everything under /sw

  • After install use FinkCommander

Complete your mac tools 2

Complete your Mac tools (2)

  • Add the fink distribution to your path

    • Easy:

      • more “test -r /sw/bin/ && . /sw/bin/” >> .profile

  • Close your terminal window and open it again.

  • Now the path should look like:

  • $ echo $PATH

    • /sw/bin:/sw/sbin:/bin:/sbin:/usr/bin:/usr/local/bin: /usr/sbin:/usr/local/teTeX/bin/powerpc-apple-darwin-current:/usr/X11R6/bin

Compile the compiler

Compile the Compiler

  • Next step is to select a Cross Compiler

  • Best:Crosstool


  • Current version 0.42

  • Supports: gcc-2.95, gcc-3.2.x - gcc-4.0.x

  • Check the current build results:


  • If you intend to compile for Motorola devices, use:

  • Crosstool for EZX


  • Current version 0.5

Compiler the compiler 2

Compiler the Compiler (2)

  • Extract the downloaded files with:

  • gzip if the file ends with .gz

  • bzip2 if the file ends with .bz2

  • (Both in fink)

  • Make sure you have ‘wget’ installed

    • the build process uses it

    • Check with: $ type wget

    • wget is /sw/bin/wget

  • You MUST be online to do the build!

    • It will get the sources to compile from websites

Compiler source download

Compiler source download

  • The scripts use wget to download the libraries and linux components defined in:

  • gcc-<version>-glib-<version>.dat

  • If you have a proxy setup, make sure that wget can work with it.

  • If you cannot get wget to work, just run the

  • It will try to access the sites, use <ctrl>-c to stop it and use a normal browser to download the needed files.

  • Place then into the download directory, usually

  • $HOME/download

  • Start again

Setup the target directory

Setup the target directory

  • At the end you will have to install your cross compiler.

  • Best to setup the directory and rights now.

  • sudo mkdir /opt/crosstool

  • sudo chown $USER /opt/crosstool

  • The following script will build the Motorola cross compiler and install the result into the same directory!

How to compile the compiler

How to compile the compiler

  • from ezx-crosstool derived from demo-*.sh

  • #!/bin/sh

  • set -ex



  • RESULT_TOP=$CROSSTOOL_DIR/gcc-arm-iwmmxt



  • GCC_LANGUAGES="c,c++"

  • export GCC_LANGUAGES

  • # Really, you should do the mkdir before running this,

  • # and chown /opt/crosstool to yourself so you don't need to run as root.

  • mkdir -p $RESULT_TOP

  • # Build the toolchain. Takes a couple hours and a couple gigabytes.

  • eval `cat arm-ezx.dat gcc-3.3.6-glibc-2.3.2.dat` sh --notest

  • echo Done.

What if there is an error

What if there is an Error?

  • Mostly errors are not really errors.

  • The Mac uses different versions of GNU Utilities.

  • Look at the error and see what produced it.

  • E.g. Error in an awk-script is not the script:

    • Use fink and install ‘gawk’

    • Run “./” again

    • Mostly the error is gone.

  • Unfortunately it does take hours and the “./” always starts from the beginning.

Expected error

Expected Error

  • There is an expected error:

  • At the end it will complain about:

    • PATH_MAX is undefined

  • This is to be ignored.

  • ALSO (known):

  • Apple make does have a bug/feature:

  • .m files are treated differently! (Objective-C)

  • Get a make from gnu and compile it separately

  • Copy it in /sw/bin do not copy it in /usr/bin!

Distributed compile

Distributed Compile

  • Once you are done, you will have a cross compiler for your embedded device.

  • If you happen to have more than one Mac, you can distribute the cross compiler and compile in your network.

  • Tool to use is‘distcc’ which is part OS X Xcode.

  • (Very advanced, I have not tested it yet.)

Cross compile trick

Cross-compile Trick

  • Some developers prefer to use a different shell for the cross compilation.

  • This assures that the builds do not interfere.

  • E.g. ‘tcsh’ uses‘.tcshrc’

  • Set the PATH and other values to the target compiler.

  • And do not forget:

  • ./configure --host=arm-linux

  • This tells configure that you are cross compiling

Set the environment

Set the environment

  • The PATH must be set to the cross compiler:

  • PATH=/opt/crosstool/gcc-3.4.5-glibc-2.3.3/arm-linux/bin:…

  • Also set the environment variables:

  • AR=arm-linux-ar

  • CC=arm-linux-gcc

  • CXX=arm-linux-g++

  • LD=arm-linux-ld

  • RANLIB=arm-linux-ranlib

  • STRIP=arm-linux-strip

Tools for mac

Tools for Mac

  • iTerm as xterm substitute, it supports bookmarks:


Tools for mac 2

Tools for Mac (2)

  • Fugu to copy over ssh


Utilities for mac

Utilities for Mac

  • Some devices use Ethernet over USB:

  • Get the Mac driver at:


  • Originally for the Zaurus, but works with most USBLan or USBNet enabled devices.

  • If you want to enable a device this way, look at:





Rokr E2


  • Login