Skip to content

API: C API: Compilation And Linking

Samuel Li edited this page Oct 7, 2023 · 2 revisions

SPERR is written in C++, so its C++ API should be used when other C++ projects want to integrate SPERR. However, a C API is easier to integrate with projects in other programming languages, for example, C, Fortran, and Python. As a result, SPERR provides a C API as well.

Compilation And Linking

This is a 3-step process:

  1. SPERR can be compiled as usual, and it should be configured to:
    1. with option BUILD_SHARED_LIBS=ON to produce a dynamic library, and
    2. install to a custom destination by specifying the CMAKE_INSTALL_PREFIX field of CMake.
  2. When compiling your project, you should include header SPERR_C_API.h which provides a set of C functions.
  3. Finally, your project should be dynamically linked against libSPERR.so (or libSPERR.dylib) to make use of SPERR compression.

This example Makefile demonstrates this usage.