The librarystal is a portable, easy-to-use and lightweight suite of auxliary library with high performance used for front-end apps. It's goal is to provide the most useful and popular APIs that could likely help for building higher-level applications and tools.
At the time of writing, libcrystal is bundled with the following modules:
- Linkedlist
- Linkedhashtable
- Ids_heap
- Bitset
- Rc_mem
- Timerheap
- Spopen
- Vlog
- Base58
- Crypto
- Posix API adaptions on Windows.
CMake is required to build and test this project in an operating system with compiler-independent manner.
At the time of this writing, the compilation works on MacOS, Linux (Ubuntu, Debian etc) and even Windows.
Sodium is a set of library for encryption, decryption, signatures, password hashing and more. With reference to libsodium, the compilation with Crypto module would be possible to proceed in the end with a build distribution containing Crypto feature.
CUnit is well-known as an automated test framework for 'C'-based program. With that, unit-test suites for libcrystal APIs could be compiled and run on your device.
Pthread is a set of pthread APIs with POSIX 1003.1c standard for Windows platform. You have to choose to use regular pthread-win32 or lightweight slim-pthread when building libcrystal on Windows platform.
Assumed that libraries libsodium and libcunit have been compiled and distributed under the directory YOUR-DEPS-PATH with following structures:
|--include
|--CUnit
|--sodium.h
|--sodium
|--lib
|--libcunit.a (or cunit.lib)
|--libsodium.a (or sodium.lib)
Then use the following series of commands to build the project with full features on Unix-like operating system:
$ git clone https://github.com/iwhisperio/libcrystal.git
$ cd libcrystal
$ mkdir build && cd build
$ cmake -DENABLE_SHARED=ON \
-DENABLE_STATIC=ON \
-DENABLE_CRYPTO=ON \
-DWITH_LIBSODIUM=YOUR-DEPS-PATH \
-DLIBSODIUM_STATIC=ON \
-DENABLE_TESTS=ON \
-DWITH_LIBCUNIT=YOUR-DEPS-PATH \
-DCMAKE_INSTALL_PREFIX=dist ..
$ make
$ make install
On Windows, besides option -DWITH_PTHREAD, the extra CMake option -G should be used with following commands:
$ cmake -G"NMake Makefiles" \
-DENABLE_SHARED=ON \
-DENABLE_STATIC=ON \
-DENABLE_CRYPTO=ON \
-DWITH_LIBSODIUM=YOUR-DEPS-PATH \
-DLIBSODIUM_STATIC=ON \
-DENABLE_TESTS=ON \
-DWITH_LIBCUNIT=YOUR-DEPS-PATH \
-DWITH_PTHREAD=YOUR-DEPS-PATH \
-DCMAKE_INSTALL_PREFIX=dist ..
$ nmake
$ nmake install
With Shorthand, run the command below:
$ DEPSDIR=YOUR-DEPS-PATH ./compile.sh
With compilation using ENABLE_TESTS option, run the commands to verify the APIs on MacOS working or not::
$ cd dist/bin
$ DYLD_LIBRARY_PATH=../lib ./unit_tests
Or on Linux:
$ cd dist/bin
$ LD_LIBRARY_PATH=../lib ./unit_tests
and on Windows, just run the commands:
$ cd dist/bin
$ unit_tests.exe
Welcome the contributions about ideas or new modules that could enrich this project.