After a very long time, I manage to create and FMU that actually works with OpenModelica with fmu.nim.
FMU - Functional_Mock-up_Interface) is a kind of file that it is used for simulation. Basically is a zip file that contains libraries (.so / .dll), .xml, . html, source code, ... and it is used to exchange simulation models accross different applications. For example, you can create a thermodynamic model in Proosis and export it to an FMU. Then you can create a control model in Matlab and integrate both models in Dymola.
I created a model that simple increase a counter in 1 every second. The model is inc.nim. When you compile this with:
nim c -r -d:fmu inc
you get inc.fmu.
Later you can import this model in OpenModelica, create a model using it and perform a simulation:
It took me years (starting and stopping the project). For a pro-dev this is probably easy. But this says a lot about how good Nim is. Enabling a non-pro dev being able of doing something like this.
Next step will be easy (I think). By compiling the model with zig, I think I will be able to create FMU's that work in Windows and Linux at the same time.
Next step will be easy (I think). By compiling the model with zig, I think I will be able to create FMU's that work in Windows and Linux at the same time.
While the Zig compiler you can use with Nim can cross-compile it's not a requirement. You can use MinGW with Nim directly and compile Nim modules for Windows from a Linux machine.