February 15th, 2002 - 10:23 updated March 15, 2003
Distribution version: 1.1
What: Program development tools including all files necessary to do C and C++ language compile and link (including make). GCC version: 2.95.1 (mostly).
Why: Well, I want to do onboard C/C++ development and I can, and I also want to share. This system solves the problem of development for the Z without having a separate PC Linux + cross compiler setup.
Requirements: You will need about 20 Mbyte of flash -- or about 14 Mbyte if you forgo C++. You will need an appropriate unzipper to unpack the files. To unpack on the Z, that means the Info unzip for arm available separately on the this and other zaurus web sites.
Performance: The compiler runs at about 1/3 to 1/4 as fast as x86 Linux on a 366 MHz Pentium II. The performance of the resulting executables shows a similar performance ratio (with no floating point code). This is a fast compiler, and this setup is capable of building large progams.
Issues: You must have sufficiant space in /tmp to hold the intermediate files during the compile. If you set up a very large swap file, use a ROM configuration with little available Ramdisk space, or fill up your Ramdisk with installed apps, this may be a problem. (The compiler, although involving a 5 Mb executable, does not appear to have particularly problematical memory usage, and could, if you were pressed, be used without starting the Qt.GUI)
Caveats: Well, I have not done a lot of testing, nor used C++ templates and other special features. I have compiled goodly sized C and C++ projects. I don't understand how some of the configuration stuff works and may have screwed it up. I also may have left out a utility program or shared library deemed necessary, and I certainly did leave out the standard configuration files for 'make' and a lot of unnecessary stuff like that. This thing is big and although I have a bigger CF card than you do, I would rather have my music aboard than an unnecessary library. All the executables and libraries have been stripped of debugging info -- there is no included debugger either. This did not come from a specific build of gcc -- most of the files were purloined from skiffcluster5.handhelds.org excepting the 'include' directory which is from one of the crosscompiler builds from Trolltech. I also do not know much about Unix packaging -- ipkg, tar files, etc., so I have opted for a largly manual install based on zip files. There is more than one file so that those with little more that the space needed for the installed file set will still be able to install. I have also tried to minimize the impact on the installed system of a ROM flash -- we will all want to do that from time to time. This methodology would also allow one to do the unzipping on Windows or Linux and then use some other transfer method. I typically plug my CF card directly into a laptop to do file transfer. Added Note: It has been reported that C++ exception handling is broken in this version of the compiler when used with shared libraries.
License: Go to www.gnu.org to review the appropriate license. I believe this distribution is in compliance, but could stand correction if someone knows better.
Installation Overview: There are several zip files which unpack into directories on your flash media (a 256 Mb CF card (Viking) w/fat16 in my case). There are presently three top level directories -- 'bin', 'lib', and 'include'. There is also a zip file containing only symbolic link info (did you know that Infozip could do that?) that will install links to necessary libraries in /usr/lib and to the 'include' directory in /usr/local/include. It will also be necessary to add the 'bin' directory to your path. More specifically, I have on my CF card: /mnt/cf/bin containing the top level executables (gcc, ld, etc.). This is in my $PATH. /mnt/cf/lib containing the shared libraries used by the compiler and the C++ shared library. Also the subdirector structure 'gcc-lib' has the arm specific files and the main executables such as the cc1 ('C') and cc1plus ('C++') compilers, cpp preprocessor, etc. called by gcc. /mnt/cf/include containing the include file hierarchy. The symbolic links are built so that the compiler's shared libraries (libbfd-18.104.22.168.14.so, libopcodes-22.214.171.124.14.so), some *.o object modules, the C++ runtime library (libstdc++-3-libc6.1-2-2.10.0.so as libstdc++.so and libstdc++-libc6.1-2.so.3) and the gcc-lib subdirectory can be found in /usr/lib, and the include file hierarchy can be found in /usr/local/include. There are also internal links so that the onboard libc.so.6 and libm.so.6 (from /lib) can be found as libc.so and libm.so in /usr/lib. Specifically, to unzip (I have named my Infozip unzip utility "uz" to avoid conflict with other software): for gcc_include.zip, gcc_bin.zip, gcc_lib.zip:
bash-2.05# cd /mnt/cf
bash-2.05# uz gcc_include.zip
bash-2.05# uz gcc_bin.zip
bash-2.05# uz gcc_lib.zip
bash-2.05# cd /
bash-2.05# uz gcc_symlinks.zip
Note: the symlinks will need to be recreated (with these commands) if you cold boot the Z or trash the ramdisk. Set your path to include the /mnt/cf/bin directory, i. e.,
bash-2.05# export PATH
You are now ready to compile -- for 'C' source, you would in the simplest case do, e. g.,
bash-2.05# gcc -s foo.c
to produce an a.out executable (-s to strip debugging info). For C++ programs, you need to link to the C++ runtime:
bash-2.05# gcc -s -lstdc++ foo.cpp
The 'make' utility is also included.
Concluding remarks: It's too big damn big: Well, you can save ~7Mb if you pitch C++; ditch cc1plus, the C++ runtime, and the g++-3 include file subdirectory. Alternatively, I am working on the use of a cramfs file system for the compiler, and particularly the include files. This will reduce the footprint by about 2/3. Ok, you could also take an axe to the include files, but you would have to know what you are doing Added Note: several other packagers have made cramfs images for SD/MMC cards, but they do not appear to work on CF cards because of the "unmount on suspend" behaviour of the Zaurus.
Postscript: Hey this might not work do to my goof or yours so email me with your results and problems and suggestions and brickbats (Nerf only). I am really an unrecalcitrant Forth programmer, and will not be able to help you with the trickeries of C++. I put Bruce Eckels' Thinking in C++ in my flash card and read along using Opera until the memory gives out.
Jeffrey R. Fox
Manitou Springs, CO