Use Mono 2.X on Ubuntu 14.04 LTS

Unfortunately, I had to use the Mono which version is 2.X in my project. It’s very old, released in 2012! So I installed it on Ubuntu 16.04 LTS from source and do make. Then the error occurred in doing make like this:

./.libs/libmini-static.a(libmini_static_la-mini.o): In function `mono_get_jit_tls_offset':
/home/vagrant/mono-2.11.4/mono/mini/mini.c:2506: undefined reference to `mono_jit_tls'
/home/vagrant/mono-2.11.4/mono/mini/mini.c:2506: undefined reference to `mono_jit_tls'
collect2: error: ld returned 1 exit status
Makefile:1351: recipe for target 'mono' failed
make[4]: *** [mono] Error 1
make[4]: Leaving directory '/home/vagrant/mono-2.11.4/mono/mini'
Makefile:1209: recipe for target 'all' failed
make[3]: *** [all] Error 2
make[3]: Leaving directory '/home/vagrant/mono-2.11.4/mono/mini'
Makefile:344: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/vagrant/mono-2.11.4/mono'
Makefile:419: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/vagrant/mono-2.11.4'
Makefile:344: recipe for target 'all' failed
make: *** [all] Error 2

So I ended up using Ubuntu 14.04 LTS for Mono 2.X.

The error might occur by the libraries that are gcc or something related to compilation.

How to make development environment of Go with Mono and Protocol Buffers

I joined a project, and I begin to develop an application in it. This project has used golang. So I studied it and prepared its developing environment.

This article is the what I did to make development environment of GO.

Prerequisite

What our golang project needs.

Glide

Glide manage a project dependency.

What is the difference between “go get” and “Glide”

As far as I searched, “go get” just installs a package into your local directory, and solves library dependencies. By contrast, “Glide” is package manager sort of npm. It uses a file defined depending packages.

Fresh

Fresh is an auto-reloader for a web application. When you change a file of golang or template, Fresh reload (recompile) the file automatically, and apply the web application.

Goose

Goose is a migration tool.

Provision

Add provisioning config

We’ll provision from a shell script file.

Vagrantfile

Vagrant.configure("2") do |config|
  ...
  config.vm.provision :shell, path: "bootstrap.sh"
  ...
end

Environment variable golang uses

Golang uses GOROOT and GOPATH environment variables.

To installing a custom location use the GOROOT. If you don’t want change one, you don’t need to set this environment variable.

The GOPATH is used to specify directories for a golang project.

Install Go

Install Go and set GOROOT, GOPATH and PATH.

Install go and set environment variables for go

apt-get update
apt-get -y install curl git
wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
tar -xvf go1.8.3.linux-amd64.tar.gz
mv go /usr/local

export GOROOT=/usr/local/go
export GOPATH=/vagrant/go
mkdir -p $GOPATH/bin
export PATH=$PATH:$GOPATH/bin:$GOROOT/bin
source ~/.bashrc

And You should add commands because GOROOT, GOPATH and PATH I set in bootstrap.sh doesn’t influence the vagrant environment.

The environment variables for golang in the vagrant environment

echo 'export GOROOT=/usr/local/go' >> /home/vagrant/.bashrc
echo 'export GOPATH=/vagrant/go' >> /home/vagrant/.bashrc
echo 'export PATH=$PATH:$GOPATH/bin:$GOROOT/bin' >> /home/vagrant/.bashrc

I install Glide.

Install Glide

curl https://glide.sh/get | sh

In the vagrant environment

Solve library dependency with Glide

It’s simple; you just execute above command.

Install glide

$ glide install

And install Fresh and Goose by go get.

Install Fresh and Goose

$ go get github.com/pilu/fresh
$ go get bitbucket.org/liamstask/goose/cmd/goose

Install protobuf

I referred to this article.

Install protobuf

$ curl -OL  https://github.com/google/protobuf/releases/download/v3.3.0/protoc-3.3.0-linux-x86_64.zip
$ unzip protoc-3.3.0-linux-x86_64.zip -d protoc3
$ sudo mv protoc3/bin/* /usr/local/bin/
$ sudo mv protoc3/include/* /usr/local/include/

Install Mono

I had to install an old version of Mono for the project reason. So I install it from tar ball.

This article is useful for me.

Install Mono

$ sudo apt-get install g++ gettext make
$ http://download.mono-project.com/sources/mono/mono-2.11.4.tar.bz2
$ tar xvjf mono-2.11.4.tar.bz2
$ cd mono-2.11.4
./configure --prefix=/opt/mono-2.11

$ make
$ make install

ln -s /opt/mono-2.11/bin/mono /usr/bin/mono
ln -s /opt/mono-2.11/bin/gmcs /usr/bin/gmcs