horns
GreasyDaemon.com - Your Guide to BSD Unix home - news - directory
FreeBSD OpenBSD NetBSD MacOS X Daemon News FreeBSD'zine
Getting Tools, and Pulling Teeth

When I the iBook arrived it came with the OS X installer, but no Developer Tools CD. Without those tools I would not be able to compile mysql, apache or various perl modules and system libaries. From a BSD perspective, my system was useless. What good is a system if you cannot compile some code?

I scoured the Apple website looking for compilers, but nothing was showing gcc or make as an included part of the downloadable bundles. There was the Project Builder application which seems to include some compiler tools, but it was not downloadable. Instead it has a note that a downloadable would be forthcoming. I waited several weeks and still I cannot download it. I had to resort to an alternative way of getting a OSX compatible compiler. I had installed Darwin onto my iMac at one point and I figured that I could get the binaries I needed from mounting the disk image for the Darwin Installer.

(Note: these tools are now available at connect.apple.com)

The process of mounting the disk image is a little tricky. The installer itself is a disk image with the installer application on it with a README file and another disk image which holds the Darwin filesystem which would be slapped onto the hard-drive in the install. In order to mount the embedded disk image inside the installer image I had to change the name of the embedded image. Both the installer and the filesystem disk images are named Darwin, so I renamed one and was then able to mount them both. Then I went about finding the files I thought were necessary.

I did not find gcc, but I did find cc, an Apple engineered version of gcc which is optimized specifically for their new OS. It also compiles Objective-C, an alternative to C++ which is the typical language used for Mac applications. Once I found gcc and make and the other tools I copied them from the mounted disk image onto to my harddrive. I then looked for files missing in the bin, include, libexec and lib folders to see what the Darwin image had, but the basic OSX install did not. I generating a list of missing files for /usr/bin/ in this way:

ls /usr/bin > usr.bin.txt
ls /Volumes/Darwin/usr/bin > usr.bin2.txt
diff usr.bin.txt usr.bin2.txt | grep ">"

That showed me the files which were in the image, but not on the base system. I then copied those files over to my live system. I had to do the same for all directories to make sure I had all the necessary libraries, header files and build tools. This included /usr/local on the Darwin image. Once I had all the missing files, I had to update the table of contents for archive libraries. I used ranlib to do so with this command.

find / -name \*.a -exec ranlib {} \;

This command will find any file on your system ending in .a and run ranlib on it. It will take a while to run, but once it is done you will have a fully ready system to use cc to compile your applications. To test it, create a quick C program and compile it.

File: hello.c
#include <stdio.h>

int main()
{
printf("Hello MacOS X!\n");
return (0);
}

> cc -o hello hello.c
> ./hello
Hello MacOS X!

Applications for the New OS >>

GreasyDaemon.com


FreeBSD
Powered by
UdmSearch
O'Reilly & Associates