NBitWonder

Embedded Development on Mac OS X part 1: fink and X11

by on Dec.06, 2010, under Mac OSX Development, Tutorials

This post was last modified on July 18th, 2011 at 11:51PM EST

To kick off the embedded development on Mac OSX series, we begin with the foundation for open source software on the Mac: fink and X11. Embedded hardware development requires good design software, and many of the best design packages are available as free or open source software. For Linux variants, apt-get is the goto method for installing software packages. For those on the Mac OS X platform, however, apt-get is not included in the system by default.

Note: use of fink and X11 requires the mac user to wade into the Terminal and the Unix guts of the operating system. If you are unfamiliar with Unix or the Terminal application, it is highly recommended that you familiarize yourself via some tutorials. Some well written tutorials are included here, here, and/or here.

Overview

The fink project provides a means to bring open source software to the Mac OSX platform. The project includes an apt-get style command-line interface to download software packages to the host computer, as well as a thriving community of software porters actively working to make OSS packages run natively on Mac OSX.

XCode Developer Tools

In order to get fink and X11 to work on Mac OSX, we will need a few pieces of software provided by apple. These are in the form of the XCode Developer tools. These tools are included on the OS install disc that came with your Apple hardware, or, alternatively, can be downloaded from Apple’s developer website (the site requires you to register, but registration is free).

Installing X11

Before we can install fink and begin working with open source software packages, it is very important that X11 is installed on your machine. Fink requires X11 in order to work correctly. If you are running Mac OSX 10.5 or later, X11 should be installed on your machine by default. If you are running an earlier version, however, you’ll need to install X11. A tutorial for installing X11 on Mac OSX 10.4 (Tiger) can be found here.

Installing fink

Once you have verified that X11 is installed on your machine, go here and follow the quick start instructions. In addition, a program called Fink Commander is available which provides a GUI interface to fink. This can be installed after fink is installed.

By default, fink is installed in a newly created directory, /sw, and software packages are downloaded to /sw/bin. It is possible that Mac OSX will not acknowledge this newly created directory by default. To remedy this issue, we must add /sw/bin and /sw/sbin to the PATH environment variable. Running

/sw/bin/pathsetup.sh

configures an appropriate startup dotfile (.profile, .cshrc, .zshrc, etc.) for the user’s default shell. Otherwise, the accepted way to do this manually is to use

source /sw/bin/init.sh

for bash or zsh, and

source /sw/bin/init.csh

for tcsh.

Fig. 1: Setting up the fink environment with pathsetup


Now, every time you open a new terminal window, you should have access to software packages installed using fink. With that set up, let’s install a package using fink.

Installing a simple package with fink

Once fink (and, optionally, Fink Commander) is installed, installing an open source software package using fink is fairly straightforward. Fink usage information is displayed by typing “fink” or “fink -h”. To demonstrate this, suppose I want to add a simple text-based game to my Terminal. To get a listing of available game packages, I type:

fink apropos games

Doing so brings up a list of open source game software packages, as shown in Fig. 2, below:

Fig. 2: fink apropos listing

Scrolling down the list, I find the following entry:

connect4 1.2-1011 Text-based Connect Four game

Looks good! To install this package, I type:

fink install connect4

You will be prompted for an admin password (fink needs to run as root and so uses sudo). At this point, any dependencies for the package in question will be displayed, and you will be asked whether or not you wish to install these packages as well. The connect4 package has no other package dependencies, so it will install right away. The end result of a round of connect4 is shown in Fig.3, below:

Fig. 3: Connect 4

Uninstalling Packages with fink

Text-based connect4 was fun, but after having lost a number of rounds to the computer, I decided I didn’t want it anymore. It’s time to get rid of the package.

To remove the connect4 package using fink, type:

fink remove connect4

And the connect4 package is removed. A screenshot of the terminal window is shown in Fig. 4, below:

Fig. 4: Removing a package in fink

Getting Help

For quick questions related to fink, “fink -h” and “man fink” are two quick ways to get information to basic questions about fink.

Bugs may arise in software packages installed via fink, this is not uncommon. If you are getting an error on a particular package, you may want to try running the following commands:

fink selfupdate
fink update-all

The above commands update fink and all fink packages installed on your machine, and may fix a particular error that you encounter.

Every now and then, however, a problem may arise in fink that you are unsure how to solve. When this happens, you may want to consult the help page on the fink community website. In addition, the fink community operates the #fink IRC channel, which can be an invaluable resource for getting fast, live help with your fink related problems. (Note, though, that you should try other avenues before taking up somebody else’s time on IRC).

Conclusions

Fink is a very valuable open source project, and acts as a gateway to other very useful open source software packages on Mac OSX. With fink installed, we can now proceed to installing and using other open source software packages. Join us in part 2 of the Embedded Development on Mac OS X tutorial series in which we add PCB layout software to design our own PCBs in Mac OSX.

:, , ,

3 Comments for this entry

  • Alex Hansen

    Fink needs more environment variables set than PATH (steps 2 and 3 above) to function properly. Running

    /sw/bin/pathsetup

    configures an appropriate startup dotfile (.profile, .cshrc, .zshrc, etc.) for the user’s default shell.

    Otherwise, the accepted way to do this manually is to use

    source /sw/bin/init.sh

    for bash or zsh, and

    source /sw/bin/init.csh

    for tcsh.

  • David Fang

    I wuold add that the very first step is to Install the Xcode Developer Tools, either from download (free registration required at developer.apple.com) or install disc. The latest versions are typically recommended.

    Nice introduction!

  • George

    Alex, David, thank you very much for your feedback on the tutorial. I went ahead and incorporated your suggestions into the tutorial. Again, thanks so much :)

1 Trackback or Pingback for this entry

Leave a Reply

 

Google thinks you would like ...

-->