Installation

Pre-compiled binaries

We provide compiled packages of the latest release for muliple Linux distributions using the OpenSUSE build service.

We also provide three conda packages in the conda-forge community channel for Linux and Os X.

  • chemfiles package contains both the C++ and Python libraries. This is the one you want most of the time.
  • chemfiles-lib package contains the C++ library alone;
  • chemfiles-python package contains the Python binding to Chemfiles alone.
# Get all the packages
conda install -c conda-forge chemfiles

# Get the C++ and C library
conda install -c conda-forge chemfiles-lib

Building from sources

Provided you have all the required depenencies, you can also build chemfiles from sources.

Core library dependencies

In order to build the core library, you will need a C++11 capable compiler. Chemfiles is automatically tested agaist GCC (>= 4.8) on Linux, OSX and Windows (mingw-w64); clang (>= 3.3) on Linux and OS X and MSCV 14 on Windows. It was also compiled sucessfully with Intel C++ compilers. Please report any sucessfull compilation with other compilers!

Some optional functionalities of chemfiles needs aditional library:

  • The NetCDF library is needed to read and write the AMBER NetCDF format. It is available in all the package managers.

Finally, chemfiles needs uses the CMake build system, which is available in all the package managers.

On UNIX-like systems (Linux, OS X, ...)

All these dependencies can be installed in one command:

# On apt-get based distributions
apt-get update
apt-get install cmake libnetcdf-dev

# On yum based distribution (CentOS/RHEL)
yum install epel-release # The EPEL repository contains the netcdf lib
yum install cmake netcdf-devel

# On dnf based distribution (Fedora)
dnf install cmake netcdf-devel

# On OS X with Homebrew
brew tap homebrew/science
brew install cmake netcdf

On Windows

You can use either MSVC 2015 compiler, or mingw-w64 provided gcc. MSYS2 offer a package manager to install all the needed libraries. I recomend using it if you have no preference over your compiler. After the initial installation steps, you can run the following to install a recent C++ compiler:

# On 64-bits windows
pacman -S mingw64/mingw-w64-x86_64-gcc

# On 32-bits windows
pacman -S mingw32/mingw-w64-i686-gcc

You will also need to install cmake, which can be found here.

Build steps

You can get the source code from either git, or from the release page of Github. In the later case, just unpack the archive wherever you want the source code to live. To get the latest developpement version, use git:

cd where/you/whant/chemfiles/to/live
git clone https://github.com/chemfiles/chemfiles
cd chemfiles

The following command build and install chemfiles

cd chemfiles
mkdir build
cd build
cmake .. # various options are allowed here
cmake --build .
# if you whant to run the tests before installing:
ctest
cmake --build . --target install

The cmake step can be further configured by using the curse-based GUI (ccmake .) or providing some command-line arguments. Here are the most important options:

Option Default value Effect/Informations
-DCMAKE_INSTALL_PREFIX=prefix /usr/local Set the installation prefix to prefix
-DCMAKE_BUILD_TYPE=type release Set to debug for debug informations
-DBUILD_SHARED_LIBS=ON|OFF OFF Build shared library instead of static one.
-DCHFL_BUILD_DOCUMENTATION=ON|OFF OFF Build the documentation. This needs sphinx and doxygen to be installed
-DCHFL_BUILD_TESTS=ON|OFF OFF Build the test suite.
-DCHFL_SYSTEM_NETCDF=ON|OFF OFF Use the system-provided netcdf library.

For instance, to install to $HOME/local, use:

cmake -DCMAKE_INSTALL_PREFIX=$HOME/local ..