Skip to content

Source code


To compile luna from source, you'll need a system capable of configuring and compiling C/C++ code, and for the dependent libraries, ideally some kind of package manager. The instructions below refer to Unix-like operating systems, namely Linux and macOS.

Please note...

If you are having trouble installing lunaC or lunaR, you might try working with the Dockerized version instead.

Before attempting to compile Luna, please ensure that you have the following (all of which can be obtained for free):

  • a C/C++ compiler: on macOS, this can be achieved by installing Apple's XCode Command Line Tools. Open a Terminal window and type (you may get an error message if they are in fact already installed):

    xcode-select --install

  • a text editor: ensure you have a text editor that works with plain-text files (i.e. not a word processor), either old-school (e.g. emacs, nano, both of which are in the luna Docker container) or new-school (e.g. Atom, which is free, or Sublime Text, which is not)

  • R : the R project for statistical computing is obviously necessary to use lunaR -- but even if you don't plan to use lunaR, it will help when working with Luna output

  • optionally, a package manager: to obtain dependent libraries for Luna, a tool like Homebrew is very useful; follow the instructions on the linked page to install Homebrew. It is possible that you may also need to autotools installed to compile some dependent libraries; e.g. on macOS with Homebrew installed, these can be obtained by typing:

    brew install automake autoconf libtool


Many systems will have the zlib compression library installed by default. If not, you'll see an error message about a missing zlib.h file when trying to compile Luna.

Get the development version (i.e. which includes the source headers), either via a package manager such as (depending on your platform) homebrew or apt-get: e.g.

brew install zlib
apt-get install zlib1g-dev

Alternatively, obtain the source from the project website:


Beyond the preliminaries mentioned above, Luna requires FFTW3, a C subroutine library for computing the discrete Fourier transform (DFT). If FFTW is not installed on your system, choose one of the following routes to obtain it:

Option 1) Use a package manager

On a system with a package manager, e.g. such as apt or Homebrew, you can run the following to first update the required dependencies (possibly prefixing each command with sudo if needed, or installing locally):

  • On a Linux system using apt-get, first make sure everything is up-to-date:

    apt-get update 
    and then obtain FFTW:
    apt-get install libfftw3-dev

  • On a Mac using the Homebrew package manager, you might try:

    brew install fftw 

These options should install FFTW so that it is accessible system-wide, so no special steps will be necessary when compiling Luna.

Option 2) Compile FFTW from source

Alternatively, go to the FFTW download page to pull the latest source. The current version used to compile Luna is 3.3.8, which you can directly download from this link:

Let's say you download fftw-3.3.8.tar.gz to the directory /home/joe/fftw/. The following should compile and install FFTW in that directory (i.e. rather than system-wide):

cd /home/joe/fftw/

tar -xzvf fftw-3.3.8.tar.gz

cd fftw-3.3.8

./configure --enable-shared --prefix=/home/joe/fftw/

make && make install

You'll then need to set the FFTW variable when compiling Luna (and lunaR too, if compiling that from source), as noted in the next section.

Luna base

Pull the latest Luna source code from the luna-base Github repository:

git clone

Enter the luna-base folder:

cd luna-base

If FFTW libraries are accessible system-wide, to build luna:

  • On a Linux platform:
  • On macOS:
    make ARCH=MAC

To specify a non-standard location of the Luna dependencies, i.e. if these were installed in /home/joe/fftw/, then set the FFTW variable equal to that location:

  • On a Linux platform
    make FFTW=/home/joe/fftw/
  • On a macOS platform
    make ARCH=MAC FFTW=/home/joe/fftw/

Hopefully, this will result in a ready-to-run executable, luna, as well as destrat and some other files. Test these by typing ./luna, which should give something like:

 luna [sample-list|EDF] [n1] [n2] [@parameters] [sig=s1,s2] [v1=val1] < commands


$ ./destrat 
error : usage: destrat stout.db {-f|-d|-s|-v|-i|-r|-c|-n|-e}

You can copy luna and destrat to any folder, e.g. likely one that is in your path, such as /usr/local/bin/, so that you can subsequently run luna by typing luna in any folder.



LunaR is not currently supported for Windows. Use the Docker version instead.

Make sure you are running a relatively recent version of R (which can be downloaded here): lunaR was developed on version 3.5.1.

You can obtain source code directly:

git clone

Install the package by running:


If needed, you can set FFTW to the location where you compiled FFTW as follows:

FFTW=/Users/joe/fftw R CMD INSTALL luna
If the above works, this will allow you to attach the lunaR library in R:
If you don't have permission to write to the main R library, try creating a separate folder as follows:
mkdir ~/Rlib

FFTW=/Users/joe/fftw R CMD INSTALL --library=~/my-Rlib luna
Then, when in R, you'll need to call:
library(luna, lib.loc="~/my-Rlib")

Installing with devtools

Alternatively, you can try using the devtools R package to install lunaR.

If you manually installed FFTW to a nonstandard location, then set the FFTW environment variable too:

Sys.setenv( FFTW="/home/joe/fftw/" ) 

Then run the following command to pull the package source from a Github and compile it:

devtools::install_github( "remnrem/luna" ) 

If there is an issue with permissions, you might need to write this to an alternate local library, e.g. assuming the ~/my-Rlib folder exists:

devtools::install_github( "remnrem/luna" , lib="~/my-Rlib" ) 

Assuming that works, then once installed you should subsequently be able to run only this command to start the library:

** lunaR v0.25.5 31-Mar-2021
** luna v0.25.5 31-Mar-2021
If you specified an alternate library location, you'll need to add that too here:


To use the POPS and other commands, you need to enable the LightGBM library when compiling Luna. First obtain the LightGBM library on your system, following the steps described in the documentation link above. On many systems, a package manager may be able to achieve this in a single step: e.g.

brew install lightgbm

Then, when compiling Luna from source, add the LGBM=1 flag: e.g.

make -j 4 ARCH=MAC LGBM=1 

If LightGBM is installed in a nonstandard location, you can point to it with the LGBM_PATH variable. For example, to install on Linux in a local folder, following the documentation here:

mkdir ~/tmp
cd ~/tmp
git clone --recursive
cd LightGBM
mkdir build
cd build
cmake ..
make -j4
Then, when building Luna, add, for example:
cd ~/src/luna-base/
make -j4 LGBM=1 LGBM_PATH=~/tmp/LightGBM

Back to top