This page describes how to build and install the rainflow counting package from sources for different target environments.
- CMake (3.10 or higher)
- C/C++ Compiler with C99 support
- GCC 4.8+
- Clang 3.4+
- MSVC 2015+
For Python support:
- Python 3.7 or higher
- NumPy (via
oldest-supported-numpy) - setuptools, wheel, build packages
For MATLAB support:
- MATLAB R2017b or higher
Build all components including C library, Python extension, MATLAB MEX, and unit tests:
cmake -S. -Bbuild -G "Visual Studio 16 2019"
cmake --build build --config ReleaseOn Linux/macOS:
cmake -S. -Bbuild
cmake --build build --config ReleaseIf you want to use a specific MATLAB installation, set the Matlab_ROOT_DIR
environment variable before running CMake.
# Linux/macOS
export Matlab_ROOT_DIR=/usr/local/MATLAB/R2019b
cmake -S. -Bbuild
cmake --build build --config Release
# Windows PowerShell
$env:Matlab_ROOT_DIR="C:\Program Files\MATLAB\R2019b"
cmake -S. -Bbuild -G "Visual Studio 16 2019"
cmake --build build --config ReleaseAlternatively, pass it directly to CMake:
cmake -S. -Bbuild -DMatlab_ROOT_DIR=/usr/local/MATLAB/R2017b
cmake --build build --config ReleaseTo build only the MATLAB MEX file:
cmake -S. -Bbuild -DRFC_EXPORT_PY=0 -DRFC_UNIT_TEST=0 -G "Visual Studio 16 2019"
cmake --build build --target rfc_mex --config ReleaseTo build only the Python extension using CMake:
cmake -S. -Bbuild -DRFC_EXPORT_MEX=0 -DRFC_UNIT_TEST=0
cmake --build build --target rfcnt --config ReleaseTo build a Python wheel package (recommended for Python users):
cd src/python
pip install setuptools build wheel oldest-supported-numpy
python -m build -nwThis creates a wheel file in src/python/dist/ that can be installed with pip:
pip install dist/rfcnt-*.whlIf a package is published to PyPI, you can install directly:
pip install rfcntInstall directly from a GitHub release:
pip install https://github.com/a-ma72/rainflow/releases/download/rfcnt-0.5.2/rfcnt-0.5.2.tar.gz
Or from the repository:
pip install git+https://github.com/a-ma72/rainflow.gitTo use in Google Colab notebooks:
!pip install --no-build-isolation --no-deps https://github.com/a-ma72/rainflow/releases/download/rfcnt-0.5.2/rfcnt-0.5.2.tar.gz import rfcnt rfcnt.tests.examples.example_1()
After installing the Python package, run the included examples:
python -m rfcnt.run_examplesThis will execute all example scripts demonstrating various features of the package.
Build and run the C unit test suite:
cmake -S. -Bbuild -DRFC_EXPORT_PY=0 -DRFC_EXPORT_MEX=0
cmake --build build --target rfc_test --config ReleaseThen invoke the test executable:
# Linux/macOS
build/test/Release/rfc_test
# Windows
build\test\Release\rfc_test.exeAlternatively, use CTest to run tests:
cd build
ctest -C ReleaseRun Python tests after installing the package:
python -m rfcnt.run_testsFor embedded systems or microcontrollers, you can build a minimal version with only core counting functionality:
cmake -S. -Bbuild -DRFC_MINIMAL=1 -DRFC_EXPORT_PY=0 -DRFC_EXPORT_MEX=0 -DRFC_UNIT_TEST=0
cmake --build build --config ReleaseUse COAN to remove unwanted preprocessor directives and create a clean minimal version:
coan source -DRFC_MINIMAL src/lib/rainflow.c > rainflow_minimal.cEnable specific features by defining preprocessor macros during the CMake configuration:
cmake -S. -Bbuild \
-DRFC_TP_SUPPORT=1 \
-DRFC_HCM_SUPPORT=1 \
-DRFC_ASTM_SUPPORT=1 \
-DRFC_DH_SUPPORT=1 \
-DRFC_DAMAGE_FAST=1See features.rst for a complete list of available feature flags.
- Use Visual Studio 2015 or later
- CMake automatically detects the installed Visual Studio version
- For MinGW, specify:
-G "MinGW Makefiles"
- Install development tools:
sudo apt-get install build-essential cmake - For Python development:
sudo apt-get install python3-dev
- Install Xcode Command Line Tools:
xcode-select --install - Or use Homebrew to install CMake:
brew install cmake
If you encounter NumPy API version issues, ensure you're using
oldest-supported-numpy during build:
pip install oldest-supported-numpyIf CMake cannot locate your MATLAB installation:
- Verify MATLAB is installed and accessible
- Set
Matlab_ROOT_DIRexplicitly (see above) - Check that your MATLAB version is R2017b or newer
If the Python extension fails to import:
- Verify NumPy is installed:
pip install numpy - Check Python architecture matches (32-bit vs 64-bit)
- Rebuild with
--no-build-isolationflag
- examples.rst - Usage after installation
- features.rst - Available compile-time features