1 / 19

May, 2006

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: http://developer.apple.com/tools/xcode/index.html Includes all gnu compilers (4.0.1) and utilities Download is about 900MB

cathyr
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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Cross-Development on Mac May, 2006 André Krützfeldt Tokyo Jamboree #8

  2. Macintosh and Xcode • OS X does come with Xcode bundled • Newest version at: • http://developer.apple.com/tools/xcode/index.html • 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

  3. Complete your Mac tools • Make your development complete! • Use fink • http://fink.sourceforge.net/ • It installs everything under /sw • After install use FinkCommander

  4. Complete your Mac tools (2) • Add the fink distribution to your path • Easy: • more “test -r /sw/bin/init.sh && . /sw/bin/init.sh” >> .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

  5. Compile the Compiler • Next step is to select a Cross Compiler • Best: Crosstool • http://www.kegel.com/crosstool/ • Current version 0.42 • Supports: gcc-2.95, gcc-3.2.x - gcc-4.0.x • Check the current build results: • http://www.kegel.com/crosstool/crosstool-0.42/buildlogs/ • If you intend to compile for Motorola devices, use: • Crosstool for EZX • http://lsb.blogdns.net/ezx-crosstool • Current version 0.5

  6. 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

  7. 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 demo-XYZ.sh • 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 demo-XYZ.sh again

  8. 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!

  9. How to compile the compiler • build.sh from ezx-crosstool derived from demo-*.sh • #!/bin/sh • set -ex • CROSSTOOL_DIR=`pwd` • TARBALLS_DIR=$CROSSTOOL_DIR/downloads • RESULT_TOP=$CROSSTOOL_DIR/gcc-arm-iwmmxt • SRC_DIR=$CROSSTOOL_DIR/src • export TARBALLS_DIR RESULT_TOP SRC_DIR • 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 all.sh --notest • echo Done.

  10. 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 “./build.sh” again • Mostly the error is gone. • Unfortunately it does take hours and the “./build.sh” always starts from the beginning.

  11. 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!

  12. 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.)

  13. 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

  14. 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

  15. Tools for Mac • iTerm as xterm substitute, it supports bookmarks: • http://iterm.sourceforge.net/

  16. Tools for Mac (2) • Fugu to copy over ssh • http://rsug.itd.umich.edu/software/fugu/

  17. Utilities for Mac • Some devices use Ethernet over USB: • Get the Mac driver at: • http://www.dsitri.de/wiki.php?page=AJZaurusUSB • Originally for the Zaurus, but works with most USBLan or USBNet enabled devices. • If you want to enable a device this way, look at: • http://www.linux-usb.org/usbnet/

  18. Devices A1200 Rokr E2 A780

More Related