Difference between revisions of "OCaml"

From GeneWeb
Jump to: navigation, search
(Adding Dockerized Geneweb instructions)
m (Running Geneweb in a Docker container)
Line 162: Line 162:
   docker run -d \
   docker run -d \
     --name jeffernz-geneweb \
     --name jeffernz-geneweb \
     -p 2316:2316 -p 2317:2317 \
     -p 2317:2317 \
     -v ${HOME}/GenealogyData:/usr/local/var/geneweb \
     -v ${HOME}/GenealogyData:/usr/local/var/geneweb \
     jeffernz/geneweb:latest \
     jeffernz/geneweb:latest \
Line 171: Line 171:
   docker run -d \
   docker run -d \
     --name jeffernz-geneweb \
     --name jeffernz-geneweb \
     -p 2316:2316 -p 2317:2317 \
     -p 2316:2316 \
     -v ${HOME}/GenealogyData:/usr/local/var/geneweb \
     -v ${HOME}/GenealogyData:/usr/local/var/geneweb \
     jeffernz/geneweb:latest \
     jeffernz/geneweb:latest \

Revision as of 03:35, 4 May 2019

150px-Geographylogo svg.png Language: English • français

Compiling GeneWeb requires the installation of OCaml and Camlp5. Nowadays, the simplest method is to install them through OPAM (OCaml preferred package manager) that is able to manage multiple versions of OCaml on the same machine. Note that Camlp5 must be installed for each version of the compiler.

Without OPAM, the old way of doing this was to install/compile OCaml and Camlp5 all by yourself.

When Ocaml and camlp5 are installed, you can clone repository to compile GeneWeb.

Don’t forget that if your base has been built under an old version, it won't be compatible with bases built with new version: one should recover through the .gw format to migrate from one to the other.

For GeneWeb 7

Under Linux

This has been tested on a Debian in March 2018 (debian-9.3.0-i386-netinst.iso).

To install Opam/OCaml (4.07)/Camlp5 (7.06)

apt-get install opam
opam init
opam update
opam switch 4.07.0
eval `opam config env`
opam install -y camlp5 cppo dune

If ocamlfind install fails, try installing the packages pkg-config or m4 from your distribution.

Under macOS

This has been tested on OS X El Capitan 10.11.6 in February 2018.

The best way to install Opam/OCaml is to install it with Homebrew, a package management software. You have to install first homebrew in a Terminal window by typing or pasting this command:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

If this gives the error “Illegal variable name.”, switch to Bash.

Once homebrew is installed you can easily install Opam in Terminal application with these commands:

brew install opam 
opam init
opam update
opam switch 4.05

and then OCaml:

opam install -y camlp5 ocamlfind
eval `opam config env`

Before compiling GeneWeb you need to update Bash with Homebrew in a Terminal window:

brew install bash 

Do not take into account the caveats about Bash path. You can now download and compile GeneWeb.

Under Windows using Cygwin

This has been tested on Windows 7 x64 and x86 in February 2018.

If you have Windows Powershell (embedded in Windows since XP SP2), this batch script will download/compile/install Cygwin/Opam/OCaml/Camlp5/Ocamfind/GeneWeb for you. You can download the script copying this line on a Windows prompt (command line) with administrator rights:

powershell.exe -Command (new-object System.Net.WebClient).DownloadFile('https://gist.github.com/a2line/f134c88c80eafcf0411b38e32a0a7128/raw/','opamwin.bat')

Then just launch the downloaded script typing opamwin in the same console to install everything.

Without Powershell, you have to download the batch file opamwin.bat and the right Cygwin setup x64 or x86 manually. Launch the script under a prompt with administrator rights and having Cygwin setup in the same directory.

GeneWeb 6.xx with OPAM

Under Linux

Sources of GeneWeb 6.04, 6.05 and 6.08 can be build easily with Opam switching to OCaml 3.12.1 (see #435). On Debian:

opam switch 3.12.1
eval `opam config env`
opam install -y camlp5 ocamlfind

When using Opam on old sources, we need to replace the path to Camlp5 CAMLP5D=+camlp5 in tools/Makefile.inc with a sed command after configuring Makefile:

sed -i 's|CAMLP5D=+camlp5|CAMLP5D=~/.opam/3.12.1/lib/camlp5|' tools/Makefile.inc
make distrib

You can check the path to Camlp5 with camlp5 -where or ocamlfind query camlp5, for this exemple camlp5 lib is in /root/.opam/3.12.1/lib/camlp5/.

Under OSX

Apply the same process as with Linux, with the exception of the sed command:

sed -i .bak 's|CAMLP5D=+camlp5|CAMLP5D=~/.opam/3.12.1/lib/camlp5|' tools/Makefile.inc
make distrib

Under Windows

Previous chapter for Linux works for Windows under Cygwin modifying a few steps, OCaml version name is:

opam switch 3.12.1+mingw32

Using relative path or /cygdrive/… don’t work, we must target camlp5 lib using its full Windows path that depends of where is your home directory in Cygwin installation:

sed -i 's|CAMLP5D=.*|CAMLP5D=c:\\cygwin\\home\\user\\.opam\\3.12.1+mingw32\\lib\\camlp5|' tools/Makefile.inc

Building version 6.07 like this also works under Windows.

Clone repository and compile GeneWeb

GeneWeb uses the version control software Git. Its repository is hosted on Github at https://github.com/geneweb/geneweb. To compile GeneWeb, you need OCaml.

git clone https://github.com/geneweb/geneweb
cd geneweb
./configure && make && make distrib

If GeneWeb compilation fails, look at continuous integration tools to see if latest build is passing on your plateform.

Build options

./configure options:

     show this help
     build the API
     add debugging symbols to the build command
     run configure interactively
     statically link libraries
     treat warnings as errors

For example, if you want debug symbols/warnings use ./configure -d -we then you can launch gwd adding OCAMLRUNPARAM=b to trigger the printing of a stack backtrace when an uncaught exception aborts the program.

Build GeneWeb gui

Since version 6.xx, an user friendly GTK gui helps managing gwd and gwsetup, it can be build with lablgtk installed.

 opam install lablgtk
 make everything

Running Geneweb in a Docker container

Download and install docker for your operating system from Docker.

To download the latest Dockerized image of Geneweb, open your favourite terminal and execute:

 docker pull jeffernz/geneweb:latest

The above command will download the latest Dockerized image of Geneweb

To run the Geneweb docker image as a container, run:

 docker run -d \
   --name jeffernz-geneweb \
   -p 2316:2316 -p 2317:2317 \
   -v ${HOME}/GenealogyData:/usr/local/var/geneweb \

This will now launch the Geneweb portal at http://localhost:2317 and the Geneweb setup portal at http://localhost:2316

To run the Geneweb portal by itself, the command is:

 docker run -d \
   --name jeffernz-geneweb \
   -p 2317:2317 \
   -v ${HOME}/GenealogyData:/usr/local/var/geneweb \
   jeffernz/geneweb:latest \

To run the Geneweb Setup by itself, the command is:

 docker run -d \
   --name jeffernz-geneweb \
   -p 2316:2316 \
   -v ${HOME}/GenealogyData:/usr/local/var/geneweb \
   jeffernz/geneweb:latest \

Additional running options

We can provide additional options when you run the docker Geneweb image

To run Geneweb in a different language:


To change the host ip-address when accessing Geneweb Setup portal

 -e HOST_IP=

Geneweb bases storage

Once you run Geneweb in the dockerized container, the bases created in Geneweb will be stored under:


Backing up the bases

To backup your bases on a running container:

docker exec -it \
   jeffernz-geneweb \

The backup will be stored under


GeneWeb/OCaml/Camlp5 compability chart

GeneWeb Ocaml Camlp4/5
1.07-2.07 2.01-2.02 p4*
3.01-3.03 2.01-2.04 p4*
3.04-3.07 2.01-3.00 p4*
3.08-4.01 3.00 p4*
4.02 3.01 p4*
4.03 3.02 p4*
4.04-4.07 3.04
4.08-4.09 3.06 p4*
4.10 3.08
5.02 3.11 p5 6.02.1**
6.00-6.08 3.12.1 p5 6.04-6.16
7 master 4.02.3-4.0.7 p5 6.13-7.07

* “same version number” for camlp4 as Ocaml version number

** Dominique Deram, compilation under Windows XP (jan. 2011)

GeneWeb Manual

Rembrandt Old Man Reading a Book.jpg

Use and manage genealogical databases

Technical annex