Skip to content
alexspeller edited this page Mar 20, 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

[thanks to Eric MacAdie]

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++

  4. You will need to recompile ruby with the new gcc - this is very important!

  5. 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.2.gem

See #34 if you have any issues.

Clone this wiki locally