MacPorts Notes |
Home Class Info Links |
Lectures Newsgroup Assignments |
This course uses the gcc compiler and, to a lesser extent, the Unix or Linux environment, both for consistency, and to expose you to the platform used by many practitioners in computer science. MacOS X comes with the gcc compiler already installed. MacPorts, somewhat like the CygWin installer, is an application that makes it easy to download and install open-source software packages, such as CppUnit, a C++ testing framework.
The Apple Developer Connection has a very nice article on how to install MacPorts, use MacPorts to install other code, and build an XCode project using the code installed by MacPorts. You should read that article first. Our notes below show what to do to use MacPorts to install and test CppUnit.
First, make sure you have XCode installed. It's on the developer CD that came with your Macintosh. If you don't have it, you can get it from Apple. It's a very big download, so use the CD if you have it.
Next, download and run the current version of the MacPorts installer from the MacPorts website.
Installing software packages with MacPorts is very easy. We'll show how to use it to CppUnit. The same steps would work with any other package.
The default way to run MacPorts is to enter text commands in a Terminal window. There are graphical front-ends as well, but the command lines are very simple for what you'll need to do, so that's all we'll show here.
sudo port install cppunit +universal
port
is the MacPorts program.
port arguments...
to do
all MacPorts actions.port
with
sudo,
to get adminstrative access. sudo
will ask for your password.cppunit
is the name of the package you want to get.
There are hundreds of packages available.+universal
means you want the "universal" variant
of this package. Universal means the code has been compiled to run
on Intel and pre-Intel Macintoshes. By default, that's what XCode wants
for released software. (You can change that default but that's outside
the scope of this course.)/opt/local/lib
and the header files should be in
/opt/local/include
.
To test that CppUnit is installed and working correctly, follow these example XCode project setup instructions. These files have code that define some simple test cases. Some of these tests are supposed to fail, in order to show you what that looks like.
Comments? Contact the Prof!