From Wikibooks, open books for an open world
Jump to: navigation, search

Ruby is a general-purpose object-oriented programming language.


rglpk is a Ruby language binding for GLPK. It is licensed under the GNU Lesser General Public License, version 2.1. Rglpk is available as a gem (a packaged Ruby library) hosted on The project homepage is


Before installing rglpk, an appropriate version of GLPK must be installed. Use the following procedure to find out which version of GLPK is required

  • open
  • follow the download link (cookies must be enabled) and save the file
  • unpack the gem file — it is in tar.gz.tar file format (you can unpack it with 7-zip or tar)
  • unzip data.tar.gz
  • read file

For instance, GLPK 4.44 is needed for rglpk-0.26.

Installation on GNU Linux[edit]

rglpk is installed using the following command

gem install rglpk

Under Debian Wheezy, the following also worked

sudo apt-get install ruby1.9.1 ruby1.9.1-dev glpk
sudo gem install rglpk

Installation on Windows[edit]


The development kit must be set up as described at

cd C:\DevKit
ruby dk.rb init
ruby dk.rb install

Building GLPK[edit]

As noted above, the GLPK version must match the rglpk version.

The following instructions worked for Ruby Installer 1.9.3-p0. Adjust the directories to suit your system

cd /C/temp/glpk-4.44
make check
make install
cp include/glpk.h /C/Ruby193/include/ruby-1.9.1
cp src/.libs/libglpk.a /C/Ruby193/lib

Building rglpk[edit]

Building and installing the gem is straightforward

gem install rglpk

Checking the installation[edit]

You can check the installation by issuing

gem query local


Ruby-FFI is a ruby extension for programmatically loading dynamic libraries, binding functions within them, and calling those functions from Ruby code.[1]. You can install ffi with

gem install ffi

Ffi-glpk[2] uses FFI to load the GLPK library and supplies wrapping for some of the API functions. It is published under a BSD license.

Ffi-glpk can be downloaded from [1].