Difference between revisions of "OCaml"

From GeneWeb
Jump to navigation Jump to search
m (→‎Clone repository and compile GeneWeb: update configure for gw build)
 
(38 intermediate revisions by 3 users not shown)
Line 10: Line 10:
 
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 [[GWformat|'''.gw''' format]] to migrate from one to the other.
 
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 [[GWformat|'''.gw''' format]] to migrate from one to the other.
  
== For GeneWeb 7 ==
+
== GeneWeb 7 ==
 
 
 
=== On Linux ===
 
=== On Linux ===
==== Debian Stretch / Buster ====
+
If needed, the command for Debian Stretch 9.9/Buster 10.0 and Ubuntu Bionic Beaver 18 dated from Q2 2019 can be found in this [https://geneweb.tuxfamily.org/w/index.php?title=OCaml&oldid=4170#Debian version of the page].
This has been tested on [https://www.debian.org/distrib/ Debian] Stretch and Buster in July 2019 (debian-9.9.0-amd64-netinst.iso and debian-10.0.0-amd64-netinst.iso).
 
  
To install Opam (2.0.5) / OCaml (4.07.01) / Camlp5 (7.06.10)
+
==== Debian/Ubuntu ====
 +
This has been tested in December 2023 with Debian Buster 10.13-Bookworm 12.2 i386*/amd 64 netinst images and also with Ubuntu Jammy Jellyfish 22.04.3 LTS. It installs Opam (2.0.3 Buster/2.1.2 Bookworm+Jellyfish), OCaml (4.14.1), camlp5 (8.02.01) and all the required Opam dependancies to build Geneweb.
 
<pre>
 
<pre>
 +
sudo apt -y install libgmp-dev opam xdot
 +
opam init --compiler=4.14.1
 +
eval $(opam env --switch=4.14.1)
 +
opam install -y calendars.1.0.0 camlp5 camlp-streams cppo dune jingoo markup oUnit ppx_blob ppx_deriving ppx_import stdlib-shims syslog uucp uutf uunf zarith
 +
opam pin unidecode 0.2.0
 +
</pre>
  
sudo apt-get install curl make m4 unzip bubblewrap gcc libgmp-dev
+
Note that libgmp-dev/zarith are needed only if you want to build with {{c|--sosa-zarith}}.
sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)
 
opam init
 
eval $(opam env)
 
opam install camlp5 cppo dune.1.11.4 markup stdlib-shims num zarith uucp unidecode
 
</pre>
 
  
If ocamlfind install fails, try installing the packages {{c|pkg-config}} or {{c|m4}} from your distribution.
+
<nowiki>*</nowiki> Beware that Debian i386 (32 bits) versions also build, except gwrepl.exe that fail: you need to remove bin/gwrepl/dune line from Makefile before configure.
  
==== Ubuntu Server ====
+
==== Raspbian ====
This has been tested on [https://ubuntu.com/download/server Ubuntu Server] 18.04.2 LTS in July 2019.
+
This has been tested on [https://www.raspberrypi.org/downloads/raspbian/ Raspbian] GNU/Linux 10 (Buster) in July 2019.
  
To install Opam (2.0.5) / Ocaml (4.07.1) / Campl5 (7.06.10)
+
To install Opam (2.0.4) / Ocaml (4.07.1) / Campl5 (7.06.10)
 
<pre>
 
<pre>
sudo apt-get install curl make m4 unzip bubblewrap gcc libgmp-dev
+
sudo apt-get install curl make m4 unzip bubblewrap gcc libgmp-dev git
 
sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)
 
sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)
 
opam init
 
opam init
Line 40: Line 40:
 
</pre>
 
</pre>
  
====  Raspbian ====
+
See also the detailed tutorial [[raspbian|installing GeneWeb 7 as webserver on a Raspberry Pi OS]].
This has been tested on [https://www.raspberrypi.org/downloads/raspbian/ Raspbian] GNU/Linux 10 (Buster) in July 2019.
+
 
 +
=== macOS ===
 +
Installing Opam on MacOS is described in https://opam.ocaml.org/doc/Install.html.
  
To install Opam (2.0.4) / Ocaml (4.07.1) / Campl5 (7.06.10)
+
It is recommended (possibly mandatory) to use the latest switch for Ocaml (4.13.0, 4.14.0)
 
<pre>
 
<pre>
sudo apt-get install curl make m4 unzip bubblewrap gcc libgmp-dev git
+
opam switch create ocaml.4.13.0
sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)
 
opam init
 
eval $(opam env)
 
opam install camlp5 cppo dune.1.11.4 markup stdlib-shims num zarith uucp unidecode
 
 
</pre>
 
</pre>
  
=== On macOS ===
+
==== former version of this section (2019) ====
 
This has been tested on macOS High Sierra 10.13.6 in July 2019.
 
This has been tested on macOS High Sierra 10.13.6 in July 2019.
  
Line 71: Line 69:
  
 
<pre>
 
<pre>
opam switch create 4.05
+
opam switch create 4.05.0
 
eval $(opam env)
 
eval $(opam env)
 
</pre>
 
</pre>
  
 
and then OCaml and dependencies required to compile GeneWeb 7.
 
and then OCaml and dependencies required to compile GeneWeb 7.
 +
 +
<hr>
 +
NB: The first of the following steps gives an error message (sorry about formatting): <br>
 +
 +
[ERROR] Could not synchronize /Users/nspies/.opam/4.05.0/.opam-switch/sources/markup from <br>
 +
        "git://github.com/geneanet/markup.ml": <br>
 +
        "/usr/local/bin/git fetch -q" exited with code 128 <br>
 +
[markup.1.0.0-1] fetching sources failed: git://github.com/geneanet/markup.ml <br>
 +
[ERROR] Error getting source from git://github.com/geneanet/markup.ml: <br>
 +
          - git://github.com/geneanet/markup.ml
 +
<hr>
  
 
<pre>
 
<pre>
Line 85: Line 94:
 
You can now [[#Clone repository and compile GeneWeb|download and compile GeneWeb]].
 
You can now [[#Clone repository and compile GeneWeb|download and compile GeneWeb]].
  
=== On Windows using Cygwin ===
+
=== Windows using Cygwin ===
This has been tested on Windows 7 x64 and x86 in December 2019.
+
This has been tested on Windows 7 x86/x64 in November 2021, and also on Windows 10 22H2 64 in March 2023.
  
 
If you have [https://en.wikipedia.org/wiki/Windows_PowerShell Windows Powershell] (embedded in Windows since XP SP2), this [https://gist.github.com/a2line/f134c88c80eafcf0411b38e32a0a7128 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''':
 
If you have [https://en.wikipedia.org/wiki/Windows_PowerShell Windows Powershell] (embedded in Windows since XP SP2), this [https://gist.github.com/a2line/f134c88c80eafcf0411b38e32a0a7128 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''':
Line 95: Line 104:
 
Without Powershell, you have to download the batch file [https://gist.github.com/a2line/f134c88c80eafcf0411b38e32a0a7128/raw/ opamwin.bat] and the right Cygwin setup [https://www.cygwin.com/setup-x86_64.exe x64] or [https://www.cygwin.com/setup-x86.exe x86] manually. Launch the script under a prompt with administrator rights and having  Cygwin setup in the same directory.
 
Without Powershell, you have to download the batch file [https://gist.github.com/a2line/f134c88c80eafcf0411b38e32a0a7128/raw/ opamwin.bat] and the right Cygwin setup [https://www.cygwin.com/setup-x86_64.exe x64] or [https://www.cygwin.com/setup-x86.exe x86] manually. Launch the script under a prompt with administrator rights and having  Cygwin setup in the same directory.
  
== GeneWeb 6.xx with OPAM ==
+
== GeneWeb 6.xx with Opam ==
 
=== On Linux ===
 
=== On Linux ===
 
[[download|Sources of GeneWeb 6.04, 6.05 and 6.08]] can be build easily with Opam switching to OCaml 3.12.1 (see [https://github.com/geneweb/geneweb/issues/435 #435]). On Debian:
 
[[download|Sources of GeneWeb 6.04, 6.05 and 6.08]] can be build easily with Opam switching to OCaml 3.12.1 (see [https://github.com/geneweb/geneweb/issues/435 #435]). On Debian:
Line 195: Line 204:
 
| 6.00-6.08 || 3.12.1 || p5 6.04-6.16
 
| 6.00-6.08 || 3.12.1 || p5 6.04-6.16
 
|-
 
|-
| 7 master || 4.02.3-4.0.9 || p5 6.13-7.10
+
| 7.00 || 4.09.1 || p5 7.12
 +
|-
 +
| master || 4.02.3-4.14.1 || p5 6.13-7.14-8.05
 
|}
 
|}
 
<nowiki>*</nowiki> “same version number” for camlp4 as Ocaml version number
 
<nowiki>*</nowiki> “same version number” for camlp4 as Ocaml version number

Latest revision as of 19:47, 7 December 2023

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.

GeneWeb 7

On Linux

If needed, the command for Debian Stretch 9.9/Buster 10.0 and Ubuntu Bionic Beaver 18 dated from Q2 2019 can be found in this version of the page.

Debian/Ubuntu

This has been tested in December 2023 with Debian Buster 10.13-Bookworm 12.2 i386*/amd 64 netinst images and also with Ubuntu Jammy Jellyfish 22.04.3 LTS. It installs Opam (2.0.3 Buster/2.1.2 Bookworm+Jellyfish), OCaml (4.14.1), camlp5 (8.02.01) and all the required Opam dependancies to build Geneweb.

sudo apt -y install libgmp-dev opam xdot
opam init --compiler=4.14.1
eval $(opam env --switch=4.14.1)
opam install -y calendars.1.0.0 camlp5 camlp-streams cppo dune jingoo markup oUnit ppx_blob ppx_deriving ppx_import stdlib-shims syslog uucp uutf uunf zarith
opam pin unidecode 0.2.0

Note that libgmp-dev/zarith are needed only if you want to build with --sosa-zarith.

* Beware that Debian i386 (32 bits) versions also build, except gwrepl.exe that fail: you need to remove bin/gwrepl/dune line from Makefile before configure.

Raspbian

This has been tested on Raspbian GNU/Linux 10 (Buster) in July 2019.

To install Opam (2.0.4) / Ocaml (4.07.1) / Campl5 (7.06.10)

sudo apt-get install curl make m4 unzip bubblewrap gcc libgmp-dev git
sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)
opam init
eval $(opam env)
opam install camlp5 cppo dune.1.11.4 markup stdlib-shims num zarith uucp unidecode

See also the detailed tutorial installing GeneWeb 7 as webserver on a Raspberry Pi OS.

macOS

Installing Opam on MacOS is described in https://opam.ocaml.org/doc/Install.html.

It is recommended (possibly mandatory) to use the latest switch for Ocaml (4.13.0, 4.14.0)

opam switch create ocaml.4.13.0

former version of this section (2019)

This has been tested on macOS High Sierra 10.13.6 in July 2019.

The best way to install Opam/OCaml is to install it with Homebrew, a package management software.

To install Homebrew, open a Terminal window and type or past this command:

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

Once Homebrew is installed you can continue to install Opam (and any dependencies) in the same Terminal window with these commands:

brew install gpatch protobuf darcs opam 
opam init

After the 'opam init' command, Opam will download and proceed with the installation of the latest switch (4.08.0). If installation of this switch fails, confirm "Y" when asked if the system should be cleaned up, and then enter proceed with the installation of the switch 4.05.0

opam switch create 4.05.0
eval $(opam env)

and then OCaml and dependencies required to compile GeneWeb 7.


NB: The first of the following steps gives an error message (sorry about formatting):

[ERROR] Could not synchronize /Users/nspies/.opam/4.05.0/.opam-switch/sources/markup from

       "git://github.com/geneanet/markup.ml": 
"/usr/local/bin/git fetch -q" exited with code 128

[markup.1.0.0-1] fetching sources failed: git://github.com/geneanet/markup.ml
[ERROR] Error getting source from git://github.com/geneanet/markup.ml:

         - git://github.com/geneanet/markup.ml

opam pin add --no-action markup git://github.com/geneanet/markup.ml
opam install camlp5 --unlock-base
opam install cppo dune markup stdlib-shims num zarith

You can now download and compile GeneWeb.

Windows using Cygwin

This has been tested on Windows 7 x86/x64 in November 2021, and also on Windows 10 22H2 64 in March 2023.

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

On 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:

./configure
sed -i 's|CAMLP5D=+camlp5|CAMLP5D=~/.opam/3.12.1/lib/camlp5|' tools/Makefile.inc
make
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/.

On OSX

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

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

On 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
ocaml ./configure.ml && 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:

 -h|--help
     show this help
 --api
     build the API
 -d|--debug
     add debugging symbols to the build command
 -i|--interactive
     run configure interactively
 -s|--static
     statically link libraries
 -we|--warn-error
     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

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

 opam install lablgtk
 ./configure
 make everything

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.00-5.01
5.02 3.11 p5 6.02.1**
6.00-6.08 3.12.1 p5 6.04-6.16
7.00 4.09.1 p5 7.12
master 4.02.3-4.14.1 p5 6.13-7.14-8.05

* “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