From your question, it seems that the code generated from Simulink is not compiling in the Arduino IDE due to the missing "dlfcn.h" header file. This is happening because the Arduino IDE cannot find the "dlfcn.h" file, which is typically used in systems running a general operating system. Specifically, it’s part of the GNU C library for dynamic loading of shared libraries, a feature that is generally not required in embedded systems like Arduino or Wemos D1 mini.
Since you haven’t shared your Simulink model file, I suspect that this issue arises because you are generating code using the "grt.tlc" system target file. The "grt.tlc" is designed for generating code for general systems that run an operating system. For embedded systems, such as the Wemos D1 mini, you should use the "ert.tlc" file. The "ert.tlc" is tailored for embedded systems and uses Embedded Coder to generate optimized code, which avoids including header files like "dlfcn.h" that are meant for general systems.
For more information about the different Simulink target files and their uses, you can check this documentation: https://www.mathworks.com/help/rtw/ug/compare-system-target-file-support.html. You can also refer to this MATLAB Answer for additional insights into the difference between using "grt.tlc" and "ert.tlc" as target configuration files: https://www.mathworks.com/matlabcentral/answers/28012-grt-vs-ert.
To resolve your issue, I recommend that you generate code using the "ert.tlc" file instead of "grt.tlc." You can change this in the Model Configuration Parameters under the Code Generation settings. Afterward, you can use the “packNGo” function to gather all necessary source and header files into a zip file. This can be imported into the Arduino IDE, compiled, and uploaded to your Wemos D1 mini. For more details on the "packNGo" function, you can refer to this documentation: https://www.mathworks.com/help/coder/ref/packngo.html.
I hope this helps resolve your issue. If you can share more details about your specific use case and any supporting files, I can provide more focused advice.
