How to install spglib C-API

How to install spglib C-API#


The source code is downloaded at spglib/spglib or you can git-clone the spglib repository by

% git clone



After expanding source code, go into the source code directory:

% tar xvfz spglib-2.0.0.tar.gz
% cd spglib-2.0.0

Build and install in _build directory by

% mkdir _build
% cd _build
% cmake ..
% cmake --build .
% cmake --install (probably installed under /usr/local)

Or to install under the parent directory,

% mkdir _build
% cd _build
% cmake --build .
% cmake --install . --prefix ..

Windows & Cygwin#

For windows, cmake behaves slightly differently and the following way is recommended

% cmake -DCMAKE_INSTALL_PREFIX="$(shell cygpath -w "${BUILD_DIR}")" ..
% cmake --build . --config Release
% cmake --install . --config Release

The detail of the windows installation process is discussed at


  1. Include spglib.h

  2. Link libsymspg.a or

  3. A compilation example is shown in example/


A few examples are found in example directory.