Closed JackHack96 closed 3 years ago
Are you able to share the FMU?
Sure! Here is it!
I wonder if this is an FMU issue. It fails also with FMPy
with the same error message.
Unable to load dynamic library
(windows). This error message is a bit misleading since it probably does find multiplier.dll
, but fails to find dependent .dll libraries.
FMPy also complains about Cannot locate installed MATLAB (Version 9.5)
. I do have MATLAB installed (2019b) on this machine, but probably another version (?) and don't think I have Simulink.
I dunno why it works with PyFMI..
So I ran dependency walker on the dll. It depends on the following DLLs that cannot be found on Windows:
LIBMATLABDATAARRAY.DLL, LIBMATLABENGINE.DLL, MWBOOST_SERIALIZATION-VC140-MT-1_65_1.DLL, MWBOOST_SYSTEM-VC140-MT-1_65_1.DLL
At least the boost dlls should be embedded in the FMU. Dunno about the matlab dlls. If they are FMU specific they should also be included in the FMU.
So I ran dependency walker on the dll. It depends on the following DLLs that cannot be found on Windows:
LIBMATLABDATAARRAY.DLL, LIBMATLABENGINE.DLL, MWBOOST_SERIALIZATION-VC140-MT-1_65_1.DLL, MWBOOST_SYSTEM-VC140-MT-1_65_1.DLL
At least the boost dlls should be embedded in the FMU. Dunno about the matlab dlls. If they are FMU specific they should also be included in the FMU.
That's why I have to use LD_LIBRARY_PATH environment variable (I'm on Linux), as documented here: https://it.mathworks.com/help/simulink/ug/export-model-as-tool-coupling-fmu.html
Can you test the FMU with FMPy under linux. I don't have easy access to Linux right now.
pip install fmpy[complete]
python -m fmpy.gui
Ok, I'll proceed after lunch. For now, here is the screenshot with PyFMI: See I have to export an environment variable. I'll test with FMPy later
So how do you export the environment variable so that it's picked up when you run using FMI4cpp?
I've tested with FMPy, and it just works :smile:
With FMI4cpp, I'm using CLion, and for exporting the environment variable I'm using the appropriate textbox on the launch configurations:
Hmm.. Then I'm guessing the system does not pick up the environment variable even though you define it though CLion. I don't think FMI4cpp handles library loading any differently than FMIL, which is used by PyFMI.
I would try setting the environment variable permanently.
I tried that but without luck. I even tried to print the value of LD_LIBRARY_PATH
before running the code, and it's correct.
The problem is the same with other FMUs generated from MATLAB, while other FMUs (like the example one on the official repository) seems to work.
If you can, it would be great if you could figure out if FMI Library handles loading dynamic libraries differently than I do with FMI4cpp and then perhaps make a PR if thats the case. I personally won't be able to do so.
Wow, that would be a difficult task as I'm learning C++ with this project (that's part of my thesis). Anyway, if I manage to get it working, I'll try to do a PR :D
I'm trying to write a little program that needs to load an example FMU generated from Simulink (a multiplier). It works using PyFMI but not in FMI4cpp, and specifically it's throwing an exception when trying to create a new instance.
The exception is:
Am I missing something or it's a bug?