Use Mac OSX for Assignments

Apple’s Mac OSX is a great environment for a budding Computer Scientist.  You get the ease of use of Mac OS and the power of a full Unix/Linux environment as well.  While we enjoy using Macs, there are a few things that can be done to make them more useful for students taking courses.  In particular, adding an X11 server ( and Apple’s Xcode turn these great end-user systems into full development machines.

Before you can get Xcode you need to sign up for an Apple Developer Account. The site will ask you to sign in as an apple developer. You will be given the option to create an account. An Apple Developer account is easy to set up and free. The site will look like this.

Installing is Apple’s X11 server.  An X11 server lets you run Unix-based applications that haven’t yet been ported to Apple’s proprietary Aqua interface.  The NX Client, used to connect to CASLab Linux and Solaris machines from home is an example of such an application.  The excellent is another.

The current version of ships on all recovery DVD
that shipped with Mac systems since OSX 10.3 (Panther).  If the Mac originally shipped with 10.3
(unlikely) and/or has been upgraded to 10.4, can be installed
from the Tiger install DVD.

X11 is automatically installed when you install/upgrade to 10.5 (leopard)

Install Apple’s This comes as a non-default component on the OS X installation DVD or CD, so you have to do a “custom install.” If you bought a new Mac, such as a new Intel-iMac, put in the first install DVD and find the optional packages installer, open it, check the X11 box, and install from that. The startup utility (the double-clickable X
icon) now winds up in /Applications/Utilities

One can also install Apple’s X11 SDK.  On 10.4, this is installed by default when you install the Xcode developer tools (see below).  On 10.3, it does
not get installed by default, you they may have to download Xcode again.

You can read more about Apple’s X11 implementation here.

Installing Xcode

While not required for just running the NX client, students might take this as an opportunity to install Xcode as well.  As with, Xcode also ships on Mac recovery DVDs.  If your DVDs are not available, or if you would like to make sure that you are using the latest version of Xcode, it can be downloaded from (Free registration required.)

Among other things, this will install GCC/GDB, the rest of the GNU toolchain and many other items that will ultimately be useful throughout your studies.

When you are installing Xcode it will give you some options on to what you need to install. It will look like this.

The system tools and Unix Development is requriered.

When you first open up XCode it will look like this.


As of the 2009 school year we have switched to python as the code taught in CISC 101 and 121.

Mac OS X includes Python 2.6.  However, the School of Computing makes use of the newer Python 3.  To install the latest version of Python, go to:


How to run a C/C++ program on a mac.

This requires you having Xcode.

Please note that C++/C is not like Java, in that it must be compiled for each operating system.  Always take care to ensure that your code works on the platform that your instructor wants you to code for.  This often means that you need to make sure that your code runs on the Windows or Linux lab machines.

The file HelloWorld.c contains:

int main(){ cout << "Hello, world.nn"; return;}

The file name will be HelloWorld.c and Hello.

using your c++/c code go in to the Terminal. This is the equivalent to the console on Windows or Linux for the Mac.

Then you need to convert the file to make it able to use gcc. Type this line into the terminal:

<UserName>$gcc HelloWorld.c -o Hello

That will compile the program in to gcc.

To run the program type /.Hello