Skip to content
agarie edited this page Apr 26, 2013 · 31 revisions

Linux

Ubuntu

Verified to work on versions 12.04 (precise)

sudo apt-get install libatlas-dev libatlas3gf-base
sudo ln -s /usr/lib/libgslcblas.so.0.0.0 /usr/lib/libcblas.so
sudo ln -s /usr/lib/atlas-base/libatlas.so.3gf.0 /usr/lib/libatlas.so
gem install nmatrix

If you got error in gem install, it maybe cause by a locale bug, please try:

LANG="en_US" gem install nmatrix

If you have compile link head error, please check the libcblas.so, libatlas.so and cblas.h atlas.h file with apt-file tool

apt-file search xxx.h

In some case, you have to ln -s with proper path

[thanks to Eric MacAdie]

Note from developers: We're actually really surprised this worked. GSL provides a different CBLAS than ATLAS, and they should not be compatible. If you have trouble with these instructions, see if you can find libcblas.so and make a symbolic link to that one instead.

Mac OS X

Lion 10.8.2

Follow the instructions below from 10.7.4, with the following alterations:

  1. Alter the gcc version in the scripts/mac-brew-gcc.sh from 4.7.1 to 4.7.2

  2. Change the last uncommented line in the script from make install to sudo make install - you will need to enter your password when prompted

  3. When gcc is installed, you will need to symlink differently:

sudo ln -nfs /usr/gcc-4.7.2/bin/gcc-4.7.2 /usr/bin/gcc
sudo ln -nfs /usr/gcc-4.7.2/bin/g++-4.7.2 /usr/bin/g++
  1. You will need to recompile ruby with the new gcc - this is very important!

  2. If you are using ruby-build or rbenv-install and you have an error recompiling ruby with the new compiler, check this issue, you can workaround by commenting out the following lines in the ruby-build script:

if type clang &>/dev/null; then
  if "${CC:-clang}" -x c /dev/null -E -Wno-error=shorten-64-to-32 &>/dev/null; then
    RUBY_CFLAGS="$RUBY_CFLAGS -Wno-error=shorten-64-to-32"
  fi
fi

Now it should install fine!

Lion 10.7.4

Xcode

Download Xcode from the App Store and run Install Xcode. Run Xcode and open its Preferences pane. Go to the Downloads tab and install Command Line Tools.

Homebrew

You will need Homebrew. Make sure everything's OK with brew doctor.

Upgrade GCC

Check your version of GCC:

gcc -v

If it's less than 4.3, you need to upgrade. First, check the path to the Xcode directory:

xcode-select -print-path

Check if that directory exists. If not, you will need to run something like:

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

Otherwise, you will see the following error when compiling:

Error: No developer directory found at /Developer. Run /usr/bin/xcode-select to update the developer directory path.

You can now install a newer GCC using this script that's part of NMatrix, or use Homebrew below:

brew install https://raw.github.com/Homebrew/homebrew-dupes/master/gcc.rb

/usr/bin/gcc and /usr/bin/g++ should be symlinks. Point them to the newer version:

sudo ln -nfs /usr/local/bin/gcc-4.7 /usr/bin/gcc
sudo ln -nfs /usr/local/bin/g++-4.7 /usr/bin/g++

Compile NMatrix

Clean up any previous attempts to compile:

rake clean

We want to include cblas.h but not clapack.h. Both are in /System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Versions/Current/Headers/, so we can't just set C_INCLUDE_PATH and CPLUS_INCLUDE_PATH. Instead, create a symlink:

sudo ln -s /System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Versions/Current/Headers/cblas.h /usr/include/cblas.h

Unset environment variables, in case you had previously set them:

unset C_INCLUDE_PATH
unset CPLUS_INCLUDE_PATH

Now you can compile NMatrix:

git clone https://github.com/SciRuby/nmatrix.git
cd nmatrix
bundle
bundle exec rake compile

If that worked, you can install it:

bundle exec rake repackage
gem install pkg/nmatrix-0.0.4.gem

If you receive an error similar to the following when trying to require the library:

$ irb
> require 'nmatrix'
LoadError: dlopen(...):
Symbol not found: _clapack_cgetrf

Try to install the gem with the option --with-lapacklib:

gem install pkg/nmatrix-0.0.4.gem -- --with-lapacklib

See #34 if you have any issues.

Clone this wiki locally