Skip to content

Installation

Frank Denis edited this page Dec 28, 2017 · 6 revisions

Installing libhydrogen

Downloading the source code

The source code can be downloaded from the GitHub repository: https://github.com/jedisct1/libhydrogen .

Unix-like systems

Review the Makefile file and use the make command to create a static libhydrogen.a library.

Alternatively, just add hydrogen.c to your project, and use hydrogen.h for prototypes definitions.

Windows

Use MingW with the standard Makefile.

Arduino IDE

Review the Makefile.arduino file and use the make -f Makefile.arduino command to create a zip file (requires the p7zip tool to be installed) that can be directly imported as a library in the Arduino IDE.

The header file to include in your projects is <hydrogen.h>.

Call hydro_init() as soon as possible in the setup() function of your sketch.

Usage on all systems

The hydrogen.h file contains the prototypes of all the public functions from the API, as well as the related macro definitions.

The hydro_init() function must be called before any other function of the library. This ensures optimal performance and correct initialization of the random numbers generator.

The function returns 0 on success, and -1 if the initialization procedure failed, but might complete if tried again at a later time.

#include <hydrogen.h>

void setup(void)
{
    if (hydro_init() != 0) {
        abort();
    }
}

The HYDRO_VERSION_MAJOR and HYDRO_VERSION_MINOR macros can be used for conditional compilation according to the library version. API and ABI changes will never occur without a change of the major version.