Skip to content

Source code

Preliminaries

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 Mac OS.

Please note...

We're still in the process of optimizing the installation process, especially for lunaR which is not guaranteed to work seamlessly on all platforms.... If you are having trouble installing lunaC or lunaR, try working with the Docker container for now.

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 Mac OSX, this can be achieved by installing Apple's XCode Command Line Tools. Open a Terminal window and type (you may get an error if they are already installed; to test whether they are 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
    

zlib

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
or
apt-get install zlib1g-dev

Alternatively, obtain the source from the project website: https://zlib.net

FFTW3

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: http://www.fftw.org/fftw-3.3.8.tar.gz.

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 https://github.com/remnrem/luna-base.git

Enter the luna-base folder:

cd luna-base

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

  • On a Linux platform:
    make
    
  • 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 Mac OSX 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 
usage:
 luna [sample-list|EDF] [n1] [n2] [@parameters] [sig=s1,s2] [v1=val1] < commands

and

$ ./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

Warning

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. To install, if you have the devtools package, you might try this:

library(devtools)

Optionally, if you manually installed FFTW in a nonstandard location, then set a 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:

library(luna)
** 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:
library(luna,lib.loc="~/my-Rlib")

Note

Alternatively, (e.g. if you have trouble with devtools), you can obtain source code directly:

git clone https://github.com/remnrem/luna.git

Install the package by running:

R CMD INSTALL luna

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:
library(luna)
As above, 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")