NTNU-IHB / FMI4cpp

FMI 2.0 implementation written in modern C++.
MIT License
96 stars 35 forks source link

add dll folder as loading library search path #145

Closed WeilongWen closed 1 week ago

markaren commented 1 week ago

Just to make sure I got this right:

On Windows, this PR adds the directory of the dll to be loaded to PATH (or akin to it), so that dependent DLLs can be loaded? Sounds reasonable. How about RemoveDllDirectory, does the directory not need to be searchable for the duration of the dll usage?

WeilongWen commented 1 week ago

Yeah, Some of fmu have dependent dlls. I have to add directory of the dll to the path. After the dll is loaded, entry dll is loaded successfully and already in use. RemoveDllDirectory can be release.

markaren commented 1 week ago

But what if the dependent dlls are loaded dynamically in the first dll? I assume that would cause issues? I suppose a more eloborate solution would be to keep the searchpath as long as the FMU is used.

With that said, I do suppose this resolves one class of issues.

markaren commented 1 week ago

Possible solution to #125

WeilongWen commented 1 week ago

You are right. I'm ignoring that dlls that are being dependent on May also be loaded dynamically. We can keep the search path until the fmu is released.

markaren commented 1 week ago

I'm merging this as is, as it solves an issue. Keeping the path for a longer duration can be a possible future enhancement.

WeilongWen commented 1 week ago

In the near future, I will do this.