0 Installation (v0.2)
Sentimentron edited this page 2014-10-25 05:21:21 -07:00

GoLearn is a Go library that's relatively standard apart from a few optional C dependencies. To install it, you'll need to install Go 1.2 or later first.

Installation

System dependencies

GoLearn uses Gonum's BLAS wrapper, which requires OpenBLAS or similar to be installed.

Installing a BLAS implementation

Installing OpenBLAS on Ubuntu
sudo apt-get install libopenblas-dev
Installation on OpenSUSE 13.1
sudo zypper in blas-devel cblas-devel

Completing the installation of Gonum's BLAS wrapper

After installing a BLAS implementation, type the following commands

go get github.com/gonum/blas
cd $GOPATH/src/github.com/gonum/blas
go install ./...

On Ubuntu 14.04, modify $GOPATH/src/github.com/gonum/blas/cblas/blas.go and modify the line beginning #cgo linux LDFLAGS: to read #cgo linux LDFLAGS: -L/usr/lib -lopenblas. /usr/lib should be the path to the openblas library. If not, use dpkg -L libopenblas-dev to find the path

On OpenSUSE 13.1, modify $GOPATH/src/github.com/gonum/blas/cblas/blas.go and modify the line beginning #cgo linux LDFLAGS: to read #cgo linux LDFLAGS: -lblas -lcblas.

Installing liblinear on OpenSUSE 13.1 (64 bit)

  1. Visit the liblinear site and download version 1.94. (Direct link to the zip version)
  2. Extract the file, change into it, and type make lib to build the library
  3. Copy liblinear.so.1 to /usr/lib64
  4. Copy linear.h to /usr/include
  5. Create a symbolic link to liblinear.so.1 in /usr/lib64 using ln -s /usr/lib64/liblinear.so.1 /usr/lib64/liblinear.so
  6. Run ldconfig -v | grep linear to check that the library is installed.

Installing liblinear on Ubuntu 14.04 (64 bit)

cd /tmp
wget http://www.csie.ntu.edu.tw/~cjlin/liblinear/oldfiles/liblinear-1.94.tar.gz
tar xf liblinear-1.94.tar.gz
cd liblinear-1.94 
make lib
sudo install -vm644 linear.h /usr/include 
sudo install -vm755 liblinear.so.1 /usr/lib 
sudo ln -sfv liblinear.so.1 /usr/lib/liblinear.so

Installing GoLearn's internal dependencies

After installing go and the system dependencies, type

go get -t -u -v github.com/sjwhitworth/golearn
cd $GOPATH/src/github.com/sjwhitworth/golearn/ext
go run make.go

You'll then need to add $GOPATH/src/github.com/sjwhitworth/golearn/ext/lib to an appropriate variable.

Bash (Linux)

Add the following to your ~/.bashrc file:

export LD_LIBRARY_PATH=$GOPATH/src/github.com/sjwhitworth/golearn/ext/lib:$LD_LIBRARY_PATH

Make sure to run source ~/.bashrc or restart the bash shell before continuing.

Bash (Mac OS X)

Add the following to your ~/.bashrc file:

export DYLD_LIBRARY_PATH=$GOPATH/src/github.com/sjwhitworth/golearn/ext/lib:$DYLD_LIBRARY_PATH

Make sure to run source ~/.bashrc or restart the bash shell before continuing.

Completing the installation

Run the following to complete installation.

cd $GOPATH/src/github.com/sjwhitworth/golearn
go get ./...

Common problems

On Linux and Mac OS X, you can verify that Go is installed correctly via your terminal. Try compiling the example program to verify that your installation is working correctly.

Your go directory must exist in your home directory and be writeable. If it isn't, type cd && mkdir go to create it.

Your GOPATH and PATH variables must be set correctly.

  • To verify, type echo $GOROOT and echo $GOPATH.
  • Your $GOPATH variable should include your $GOROOT, plus a bin/ directory. For example, if $GOROOT is set to /home/sen/go, $GOPATH should be set to /home/sen/go/bin
  • To make sure that these variables are setup correctly, add export GOROOT=$HOME/go and export PATH=$PATH:$GOROOT/bin to your Bash configuration file.

Support status

Operating SystemsMac OS X 10.8
Ubuntu 14.04
OpenSUSE 13.1
Go version1.2
GoLearn version0.2
Support statusCurrent
Next revisionOn version upgrade

Mac OS X 10.8

  • BLAS installation via HomeBrew has not been confirmed working.