Skip to content

wissem01chiha/slxio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

190 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SLXIO

Windows Ubuntu MacOS Documentation CodeQL GitHub License Release Coveralls CodeFactor pre-commit.ci status

Table of Contents

1.0 Overview

Slxio is an open‑source C++11 library for reading, writing, visualizing, and exporting Simulink .slx model files.

The project is designed as a lightweight alternative to MATLAB’s proprietary libraries and runtime, similar in spirit to the matio library for .mat files. Its goal is to make Simulink models accessible outside the MATLAB ecosystem, enabling manipulation and integration through modern scripting languages such as Python, Java, and others via C++ bindings.

The project was originally derived from the Java-based Simulink parser of the ConQAT Project. Find the original source code here SimulinkLibraryForJava. It has since been ported to C++ and refactored into a highly modular architecture.

Slxio does not aim to support all Simulink features, but rather focuses on the most commonly used ones. The library provides a simple and intuitive API for accessing and modifying Simulink model components such as blocks, lines, parameters, and Stateflow charts, via a mimic of the MATLAB Simulink API. This makes it easy for users familiar with MATLAB to get started.

To install the prebuilt binary of the library, refer to the Installation section and check out the latest release from the official GitHub release page,for building the library from source, see the same page for detailed instructions.

Examples and tutorials for beginners are hosted with the project and can be found on the Tutorials page, along with their source code. Many of the features are not yet implemented or tested. For a detailed list of features and their support status, see the feature section.

The project is under active development, and contributions are highly encouraged. See the Contributing guide for basics on Git, CMake, C++, and workflow, and the Development guide for quick-start instructions and advanced details.

Note

This project is still in an experimental phase. It is not yet ready for production use, and no stable release has been published.

1.1 Features

  • Read Simulink internal block‑diagram files into native C++ data structures.
  • Export model hierarchies into JSON, HDF5, or Graphviz‑compatible formats.
  • Edit metadata and parameters, then save changes back into .slx files. This feature may be delayed because Simulink files follow the Opc Convention and the archive layout changes between versions. We currently maintain the libopc project to provide a portable, cross‑version abstraction for editing.
  • Perform static analysis on Simulink models and generate reports in PDF or HTML.
  • Visualize Simulink models interactively. For now, only the Qt backend is supported. Other 2D graphing engines or tools are open for discussion — please feel free to start one here.

1.2 Supported MATLAB

Slxio aims to support MATLAB releases from R2018a to R2025a. Currently, the primary supported versions are R2019a and R2018a. Additional versions will be progressively supported in future project releases.

Note

Some new features introduced in the graphical interface (e.g., layout, formatting, annotations) by MathWorks may not be available, as the project focuses on core model/library block diagram data.

*.mdl files are out of scope, for certain specific releases they may be partially compatible, but no support or fixes are planned for mdl file compatibility.

At present, there is no official documentation from MathWorks regarding the slx data format or XML schema rules. As a result, this project relies on reverse engineering and interpretation of actual compressed slx files.

To ensure compatibility when using slxio with unsupported Simulink versions, we recommend exporting models to one of the supported versions before reading them. This process may require a valid MATLAB license. For more information, see: Simulink Export to Version.

1.2.1 MATLAB Regression Testing Matrix

Release Status Comment Release Notes
R2018a Release Notes
R2018b Release Notes
R2019a Release Notes
R2019b Release Notes
R2020a Release Notes
R2020b Release Notes
R2021a Release Notes
R2021b Release Notes
R2022a Release Notes
R2022b Release Notes
R2023a Release Notes
R2023b Release Notes
R2024a Release Notes
R2024b Release Notes
R2025a Release Notes
R2025b Release Notes

1.3 Contact

Feel free to contact the maintainer through email at mail

1.4 Contributing

If you are interested in collaborating, please see the CONTRIBUTING guide or contact the maintainer via email (see section 1.2). Due to time constraints, responses and pull request reviews may be delayed. Thank you for your understanding.

2.0 Installation

2.1 Binary Release

The easiest way to install is to visit the Releases page and download the latest release for your platform.

2.2 vcpkg

Note

slxio is not yet available on vcpkg, once it is published, you will be able to install it using:

vcpkg install slxio

2.3 Conan Recipe

See Conan.

Note

slxio is not yet available on the Conan package manager, once it is published, you will be able to add it to your project using a Conan recipe.

3.0 Building from Source

This section describes how to build slxio, see 2.1 describes the dependencies,

3.1 Dependencies

Slxio has its own modular build wrapper, written on top of CMake, similar to many open‑source projects. All core dependencies are vendored with the source code in the ThirdParty directory to maximize platform compatibility and reduce reliance on external build/fetch rules. Optional dependencies may either use system‑wide installations or be fetched externally depending on configuration options, via CMake package managers or other internal helpers.

Library Version Introduced In Depends On Notes
slog Latest v0.1.0
json-c Latest v0.1.0
zlib 1.2.8 v0.1.0
libzip 1.11.4 v0.1.0 zlib
libxml2 2.14.5 v0.1.0
TinyXML2 v0.1.0 Not yet used
HDF5 1.14.1 v0.3.0 zlib experimental
matio 1.5.28 v0.3.0 zlib, HDF5 experimental
cxxopts 3.3.1 v0.3.0 experimental
doctest 1.14.0 v0.3.0
libuv v0.3.0

3.1.1 zlib

Support for compressed SLX, JSON, MAT, and h5 file formats requires the zlib library. Version 1.2.8 of zlib is bundled with the code and will be built automatically if not found by CMake in the system path. Other versions are not officially supported.

3.1.1 HDF5

Support for MATLAB MAT files, used for reading Simulink-related data structures, is provided through matio, which itself requires the HDF5 library. Additionally, for serializing SLX files into standard .h5 data files, SLXIO depends on the HDF5 library. If the library is not found, it is automatically fetched and built via CPM. However, it is recommended to use a prebuilt binary, as this significantly reduces the build and compilation time.

3.2 Building Slxio

Building the library from source can be time‑consuming depending on your system configuration and setup. For a quicker installation, we recommend using the binary distribution for each platform

3.2.1 Quick Build Guide

mkdir build && cd build
cmake -G "MinGW Makefiles" ..
cmake --build .
cmake --install .

3.2.2 Configure Options

Option Description Default Supported Since
BUILD_SHARED_LIBS Build as shared libraries OFF
ENABLE_PYTHON_BINDING Enable building Python interface ON
ENABLE_TESTING Build C++ unit tests ON 0.1.0
ENABLE_BINDING_TEST Build binding interface tests ON
ENABLE_NAMESPACE Enable global namespace TRUE
ENABLE_ABI_NAMESPACE Enable ABI namespace (requires ENABLE_NAMESPACE=ON) ON
USE_LOCAL_LIBS Use locally installed libraries ON
ENABLE_OPENMP Enable compiling with OpenMP support ON 0.1.0
ENABLE_AVX Enable AVX optimizations where available ON
ENABLE_HDF5 Enable HDF5 support ON 0.1.0
ENABLE_MATLAB Enable MATLAB support OFF
ENABLE_PKGCONFIG Generate pkg-config file ON
ENABLE_INSTALL Enable installation after build OFF
ENABLE_SANITIZER Enable sanitizers (ASan/UBSan/etc.) OFF
ENABLE_CLANG_TIDY Enable static analysis with clang-tidy OFF
ENABLE_CPPCHECK Enable static analysis with cppcheck ON
ENABLE_CLANG_FORMAT Enable Clang-Format support mode ON
ENABLE_COVERAGE Enable code coverage reporting (GCC/Clang) OFF
ENABLE_FUZZING Enable fuzzing support OFF
ENABLE_DOCUMENTATION Enable documentation generation OFF 0.1.0
BUILD_EXAMPLES Build example applications OFF 0.1.0
CMAKE_INSTALL_PREFIX Default install path ${CMAKE_BINARY_DIR}/install 0.1.0

3.3 Platform Support

OS Compiler Version Arch Status
Windows 11 MSVC 19.1x x64, Win32 NA
Windows 11 MSVC 19.2x x64, Win32, ARM64 NA
Windows 11 MSVC 19.43 x64, Win32, ARM64 Windows
Windows 11 MSVC 19.50 x64, ARM64 NA
Windows 11 MinGW‑w64 GCC 11.2.0, 15.2.0 x64 MinGW
Ubuntu 22.04 GCC 11.2.0, 13.3.0 x64 Ubuntu
Ubuntu 22.04 Clang 14.0, 15.0 x64 NA
macOS 14 Apple Clang 14.0, 15.0 arm64, x64 MacOS

4.0 Testing

Slxio has moved from GoogleTest to the doctest framework for lightweight and efficient testing since version 0.1.0. Testing is enabled via the CMake option ENABLE_TESTING.

4.1 Running Tests

To run all unit tests after building, use:

ctest -C Debug --output-on-failure

This will execute all project unit tests by default.

Note: Code coverage is not yet supported.

4.2 Debugging Test Failures

If a test fails, check Testing/Temporary/LastTest.log, test/testSubDir/${testname}/${testname}.vg.out, and other similar files.

5.0 Use in Other Projects

Currently, the only supported build system is CMake. Other build systems are not planned at the moment, though they may be considered in future discussions. Below are several ways to integrate slxio into your project:

    1. Using FetchContent (built-in CMake module)

The simplest way is to use CMake’s built-in FetchContent to add slxio as an external dependency. This will automatically download, configure, and build the library alongside your application.

include(FetchContent)

FetchContent_Declare(
  slxio
  GIT_REPOSITORY https://github.com/wissem01chiha/slxio.git
  GIT_TAG master
)
FetchContent_MakeAvailable(slxio)

add_executable(app main.cpp)
target_link_libraries(app PRIVATE SLXIO::SLXIO)
    1. Using CPM.cmake (CMake Package Manager)

    If you prefer a package manager approach, you can use CPM.cmake to fetch and integrate slxio

 CPMAddPackage(
   NAME slxio
   GITHUB_REPOSITORY wissem01chiha/slxio
   VERSION 0.1.0
 )

 add_executable(app main.cpp)
 target_link_libraries(app PRIVATE SLXIO::SLXIO)
    1. Using ExternalProject

For more control, you can use ExternalProject to build slxio separately and then link it:

include(ExternalProject)

ExternalProject_Add(
  slxio
  GIT_REPOSITORY https://github.com/wissem01chiha/slxio.git
  GIT_TAG master
  UPDATE_DISCONNECTED 1
  PREFIX ${CMAKE_BINARY_DIR}/slxio
  INSTALL_COMMAND ""
)

add_executable(app main.cpp)
add_dependencies(app slxio)
target_link_libraries(app PRIVATE SLXIO::SLXIO)
    1. Using find_package

Once slxio provides proper CMake configuration files, you’ll be able to integrate it like any other modern CMake package:

find_package(slxio CONFIG REQUIRED)

add_executable(app main.cpp)
target_link_libraries(app PRIVATE SLXIO::SLXIO)

6.0 API Documentation

Since version 0.1.0, Slxio has used Sphinx for documentation. However, for detailed implementation documentation, Slxio includes integrated support for Doxygen, which can be enabled via the ENABLE_DOCUMENTATION cmake option.

7.0 References

Shrestha, S. L., Chowdhury, S. A., & Csallner, C. (2022). SLNET: A Redistributable Corpus of 3rd-party Simulink Models (v2.0). Zenodo. https://doi.org/10.5281/zenodo.5259648

8.0 License

All material is provided under an Apache License unless otherwise specified.

see the LICENSE file for more details

About

[WIP] SLXIO – SIMULINK SLX File I/O Library

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors