Skip to contents

In order to compile the underlying Pascal code, you need to install:

Setup R environment

Then, you need to be inside the package itself when developing. For this:

  • Clone the project:
git clone https://github.com/nrode/Lifelihood.git
  • Open the project in RStudio or any other editor

  • Install development dependencies: install all necessary dependencies for development, including Lifelihood itself, by running:

install.packages(c("devtools", "testthat", "roxygen2", "pkgdown"))
remotes::install_local(dependencies = TRUE)

When developing an R package, you should not use library(lifelihood), but rather:

devtools::load_all()

This allows to use the latest local version and not having re-install the package every time you make a change.

To check that everything worked as expected, run:

devtools::test()

This will run all unit tests inside the package. If everything is okay, it should print many things and ends with something like this:

══ Results ═══════════════════════════════════════════════
Duration: 4.8 s

[ FAIL 0 | WARN 0 | SKIP 0 | PASS 94 ]

Compilation

  • On macOS

Run just macos. This runs the macos script inside justfile, and will automatically update inst/bin/lifelihood-macos.

  • On Linux

Run just linux. This runs the linux script inside justfile, and will automatically update inst/bin/lifelihood-linux. If this is the first time you’re compiling, this might take some time as it will build a Docker image first.

Note that except if you’re on a Linux machine, you’ll need to have Docker installed and the Docker daemon running.

  • On Windows

The just windows command is a work in progress. You can still compile manually using Lazarus.

Open project in Lazarus

Then, open Lazarus and select “Open project”. You should select the file named lifelihood.lpi that should be in Lifelihood/source/lifelihood.lpi.

Finally, we need to set the output directory for the compiled file. You need to go in Project > Project Options > Compiler Options > Paths. In the “Unit output directory (-FU)”, set the path to Lifelihood/inst/bin/new/. In my case the full path is: /Users/josephbarbier/Desktop/Lifelihood/inst/bin/new/.

This will output all files in this directory. Then, you need take the compiled file in the new/ directory (lifelihood.exe if you compile on Windows, lifelihood if you compile on Mac.) Take that file, remove the C2023 (which gives either lifelihood.exe or lifelihood) and put it inside Lifelihood/inst/bin/. You will need to remove/overwrite previous compiled files.

You should now be able to compile the project with Run > Compile.