This page offers some help setting up Ohcount 2.0 (the Ragel branch) on Ubuntu Linux.

Installing Prerequisites

Ohcount is a Ruby application with C native extensions. Ohcount requires Ruby, Rdoc, Rake, Ragel, RubyGems, and GCC.

Happily, there are packages for most requirements:

sudo apt-get install libpcre3-dev ruby1.8 ruby1.8-dev rake rubygems

Installing Ragel

Ohcount uses a very recent version of Ragel, which is currently available only from the Subversion source control. Note that the Ragel build appears to be recursive, in that it requires a prior version of Ragel to be present in order to build.

Full details of building Ragel are beyond this documentation, but the basic steps are:

Install gperf. This is available as an Ubuntu package:

sudo apt-get install gperf

Build and install kelbst from source. Note that configure accepts an optional '--with-prefix=' parameter to set the install directory.

wget http://research.cs.queensu.ca/~thurston/kelbt/kelbt-0.12.tar.gz
tar xzf kelbt-0.12.tar.gz
cd kelbt-0.12
./configure
make
sudo make install

Build and install Ragel 6.2. Note that configure accepts an optional '--with-prefix=' parameter to set the install directory.

wget http://research.cs.queensu.ca/~thurston/ragel/ragel-6.2.tar.gz
tar xzf ragel-6.2.tar.gz
cd ragel-6.2
./configure
make
sudo make install

Finally, build and install the latest version of Ragel from Subversion. We've had good luck with revision 454:

svn export -r454 svn://mambo.cs.queensu.ca/ragel/trunk/ ragel-r454
cd ragel-r454
./configure
make
sudo make install

Getting the Ohcount Source

Ohcount source code is managed using Git. If you do not already have Git, install it now:

apt-get install git-core

Clone the Ohcount source code repository:

git clone git://labs.ohloh.net/git/ohcount.git

Build Ohcount

To build Ohcount and run the unit tests:

cd ohcount
rake clean
rake

The rakefile has some troubles with dependencies -- be sure to rake clean first.

Note: You may receive a large number of compiler errors regarding file polyglots.c. This will happen if you have installed the new Ohcount source on top of the old Ohcount source. The new Ohcount does not use a polyglots.c file at all. Simply delete ext/ohcount_native/polyglots.c and build again.

The Ohcount command line tool is in the bin subdirectory. To install Ohcount and have it available on your path and as a RubyGem?:

rake install

Notes

While building Ohcount, during the rake install step you may see an error message similar to the following:

File not found: lib/x86_64-linux

It's possible that the install has succeeded, even though you are seeing an error message. Try running ohcount to confirm the install:

$ ohcount --help

This error message is a known bug: http://labs.ohloh.net/ohcount/ticket/229#comment:2