skip to Main Content

I have a Visual Studio 2013 project, coding by C. And I generate a dll file, and put it into a directory of fmu file structrue, and there are some other sources like modelDescription.xml. I compress the dir into an fmu. And then I import it to simulink2021b by fmu block, it can be recognized as an fmu, and can update(Ctrl+D), but when I run it, it display an error:

"Error in supplied FMU: Unable to load dynamic library 'C:UsersxxxxDesktop\fmu_testsimulinkslprj_fmue06e7f3203c5e5995bff88ca17b48bdefmu-minimum65binarieswin64BaeSAR_VSP.dll': ************".  

************ is a string of codes that cannot be correctly display.

When I run it on simulink 2017b, the error ************* change into Try to access invalid addresses.

What is the problem with my fmu? How can I generate a correct fmu by VS2013? (Or other VS
version)

The project code is very simple.

I check my fmu by FMUChecker-2.0.4-win64 tool, it output some info and two errors:

[ERROR][FMUCHK] Platform type returned from CS FMU 'win64' does not match the checker 'default'
[ERROR][FMUCHK] FMU logger callback does not propagate component environment to the application`

And the next output is:

[INFO][FMUCHK] Initialized FMU for simulation starting at time 0
0.0000000000000000E+000
2.0000000000000000E+003
4.0000000000000000E+003
....
9.9800000000000000E+005
1.0000000000000000E+006
[INFO][FMUCHK] Simulation finished successfully at time 1e+06
FMU check summary:
FMU reported:
        0 warning(s) and error(s)
Checker reported:
        0 Warning(s) 
        2 Error(s)  

I had copy the dll files that this fmu dependents on into the resources dir, and make sure that they are all 64-bit, but it doesn’t work, the simulink error is still Try to access invalid addresses.

2

Answers


  1. Please use the Reference FMUs and the build process there as a blueprint how to generate well defined FMUs from C-Code.

    https://github.com/modelica/Reference-FMUs

    Login or Signup to reply.
  2. A similar issue occurs, if the FMU dll requires another dll which is not included in the FMU, or if the importing tool does not handle the dependent dlls correctly. So, you must make sure that the dependent dlls are available on the executing computer or in the FMU. You can also try to avoid dependencies by linking statically.

    You can observe the dependency tree with the dependency walker (https://www.dependencywalker.com) or reimplementations of that tool (https://github.com/lucasg/Dependencies).

    Visual Studio binaries depend on the runtime libraries (e.g. msvcr*.dll) if you set the switch "/md". If you set the switch "/mt" the dependency is linked statically to your library.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search