NTNU-IHB / FMI4cpp

FMI 2.0 implementation written in modern C++.
MIT License
98 stars 38 forks source link

Unable to load dynamic library dependencies located in FMU #125

Open mycrocs opened 2 years ago

mycrocs commented 2 years ago

When i start to simulate my fmu, it signals an error "Unable to load dynamic library xxx.dll". However, it works when i simulated in FMpy. I have used dependency walker to detect the dll, it says this image

Here are the missing dlls

image

Is it a fmu issue or a fmi4cpp issue? My fmu is a model_exchange model generated from SCADE and is win64.

mycrocs commented 2 years ago

I think the fmi4cpp cannot find libegl.dll and libglesv2.dll. The two dlls and the dll loaded are in the same directory. Does the load_library function not search that directory?

markaren commented 2 years ago

Missing DLLs in dependency walker are red. Are libegl.dll and libglesv2.dll red? How about FMUCompilanceChecker or other non-python based tools?

mycrocs commented 2 years ago

In dependency walker, they are not red. I think dependency walker will search the directory from which the dll loaded, but the load_library function won't. I try putting the two dlls in System32 directory and it works.

markaren commented 2 years ago

I had a brief check at the FMPy code, and it changes working directory prior to loading the DLL. Thus, fmi4cpp should probably do something similar, which I'm fairly sure from memory it does not. I don't have the resources to look at it though,

mycrocs commented 2 years ago

Maybe can use LoadLibraryEx instead.

WeilongWen commented 1 year ago

I have solved the problem. Actually dependent dlls path should be change before loading dynamic library. How can I contact the publisher and perhaps upload my changes?

markaren commented 1 year ago

How can I contact the publisher and perhaps upload my changes?

You mean me? You could propose a PR if a change in FMI4cpp is suggested.

markaren commented 2 months ago

This one is probably solved by #145?