How do I include the experimental/filesystem C++ header in Simulink Real-Time custom code?

20 views (last 30 days)
When compiling custom C++ code for use in Simulink Real-Time R2022a, I receive a compiler error:
fatal error: experimental/filesystem: No such file or directory
on the include statement for the "experimental/filesystem" header. The "Language Standard" option in the configuration parameters is set to "C++11", which should have this library as part of its standard library.
Why can't I include "experimental/filesystem", and how can I use its functionality in my C++ code?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 24 Jul 2023
Edited: MathWorks Support Team on 24 Jul 2023
The standard library and headers available to the Simulink Real-Time compiler are determined by the Real-Time Operating System, which compiles and runs the custom code and model. Since R2020b, this is QNX Neutrino.
This is not affected by the "Language Standard" option in the configuration parameters, which only affects code generated from Simulink, not compiler options.
The "experimental/filesystem" library was renamed to just "filesystem" in the C++17 standard, so the following include statement works:
#include <filesystem>
Alternatively, you can use the Boost filesystem library with the following include statement:
#include <boost/filesystem.hpp>
The C++ filesystem library was directly based on the Boost filesystem library, so similar functionality is present. For more information on the C++ filesystem library and its history, refer to the following external links:

More Answers (0)

Categories

Find more on Troubleshooting in Simulink Real-Time in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!