Skip to content

Install

Randall O'Reilly edited this page Jan 21, 2020 · 30 revisions

Installation

This wiki provides an umbrella wiki for all emer projects. The emergent repository itself does not contain directly runnable code (except for tests) -- it serves as a toolkit for other specific algorithms.

Currently the only implemented one is in the leabra repository. Thus, you need to install that to see how emergent works.

In general, emergent works by compiling programs into executables which you then run like any other executable. This is very different from the C++ version of emergent which was a single monolithic program attempting to have all functionality built-in. Instead, the new model is the more prevalent approach of writing more specific code to achieve more specific goals, which is more flexible and allows individuals to be more in control of their own destiny..

Go Modules

Recent versions of Go have switched to using the modules system by default, and you probably want to turn that back off before building. Here's some links to information about modules:

Basically, they provide a nice way to guarantee (as much as is possible) that a given version of a software package will build and work, by specifying all the versions of all of the dependencies of that package that enable it to build and work properly. However, the downside is that this only works for a "frozen" version tagged snapshot of the package, and not necessarily for the current GitHub version. Also, it installs all of the dependencies in a secret hiding location, making it hard to see and use all that other source code. We regularly update the go.mod modules information for all of the emer and GoKi packages that we develop, but only when a new version is released. If using modules, you generally must use that tagged version and not the current HEAD version on GitHub (i.e., git checkout <version> e.g., git checkout v1.0.0)

The non-module version of Go just installs all the code under the single master ~/go/src/github.com/... (i.e., GOPATH) tree, and it is easy to find everything there. However, that is always the current bleeding-edge version of the code, which generally works but sometimes may not. The instructions etc here all assume that you've got the non-module install.

To turn modules off, add this line to your ~/.bashrc or ~/.bash_profile or whatever is run when your shell starts:

export GO111MODULE=off

you can also make aliases to toggle this on and off if you want to switch between modes.

First, install GoGi

Emergent depends on GoGi, so first follow the installation instructions for it, including building the standard widgets example to make sure everything is working. This is essential especially because there are non-Go elements that need to be installed to support the 3D GUI, which won't be installed with the generic go get command.

Then install leabra

Typically in Go you want to install at the level of a specific final executable package, because it will include all the other packages (libraries) that are needed. Thus, we first use the go get command to grab the specific package containing this target executable, and then we run another go get command to grab all the other dependencies:

> go get github.com/emer/leabra    # ignore any warnings about no go files, etc.
  • Go to the examples/ra25 directory and make sure all dependencies are installed (and updated)
> cd ~/go/src/github.com/emer/leabra/examples/ra25    # use `$GOPATH` instead of `~/go` if you have that set
> go get [-u] ./...    # the -u (update existing) may be needed but will take a lot longer -- try without first..
  • Important: IGNORE any error messages you see from go get (including "no go files..") -- the only thing that matters is what happens with go build! get somehow gets confused with a few things..

  • Finally, build and run the executable:

> go build     # any errors here are likely fatal.. file an issue (again, install gogi first!)
> ./ra25  # this will run the program

To make your own simulations, copy the ra25.go code to your own repository, and modify accordingly, then you can just do go build to make it. Also, you can look at the revision history of this file after you've copied, to see any updates we've made (bug fixes, new features).

go build options

You can run go build either specifying a particular .go file, or without (i.e., just go build as in above instructions).

  • If you have multiple .go files in same dir that all contribute to one executable, then you have to run go build, and the resulting executable will be named after the directory.

  • If you have multiple .go files and each should be built as a separate executable, then you have to run go build file.go and the executable will be named after the file.

  • If you only have one .go file, you can decide what you prefer.