ali bütün
Hello,
I am working with a C/C++ Function Block in an OpenPLC project. The project compiles and runs correctly as long as all the code is placed inside a single .cpp file.
However, I would like to split my code into multiple files. I created a header file (example.h) and tried placing it in several different directories (including the Function Block folder and other project folders), but I cannot get it to be recognized by the compiler.
When compiling the project, I always receive the following error:
 
fatal error: example.h: No such file or directory

Is there a supported or recommended way to add and include custom header files in OpenPLC C/C++ Function Blocks?
If so, which directories are included in the compiler include path during the build process?

Thank you in advance for your help.
Reply 0 0
thiagoralves
The implementation for C/C++ and Python blocks is self-contained. The entire code for the block needs to be declared at the same place. This means that currently there is no way to include external headers, except for system libraries that are already on the include path. The purpose of the C/C++ blocks is to aid in the development of the PLC program logic that can’t be done using traditional IEC languages. Although it would work, it is not meant to be used for hardware access or more complex things. In that case you probably need to look for the plugin system that allows extending the runtime with custom code. See the documentation about the plugin system here: https://github.com/Autonomy-Logic/openplc-runtime/tree/development/core/src/drivers
Reply 0 0
Reply