C++ DLL not working when used inside Experimenter (works fine outside)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I’m currently developing a custom C++ DLL to improve the performance of a Dijkstra algorithm that calculates shortest paths in my FlexSim model. The DLL returns an array of size 2: the route to follow and its corresponding weight.
Previously, we used an external Python script for this purpose, and it worked correctly both inside and outside of the Experimenter. After switching to the C++ DLL implementation, the code still runs perfectly when I execute the model directly, but it stops working when executed through the Experimenter. It doesn’t crash — it simply returns an empty array, and then each scenario logically fails.
Diagnosing the issue has been difficult because the DLL doesn’t seem to write any logs while running inside the Experimenter (I might be doing something wrong here). I’ve also confirmed that the “Apply the following scenario and replication to the model?” option confirms the error. Interestingly, when I try to debug a failed scenario from the Experimenter in the model directly, the model starts working normally again.
My questions are:
- Does the Experimenter fully support the use of external C++ DLLs in this way?
- Could this be related to threading or memory-safety issues within the Experimenter’s environment?
- Are there any common pitfalls or recommended debugging approaches for DLLs used in Experimenter runs?
I’d also appreciate any advice on how to effectively log or debug code that runs inside the Experimenter, since traditional file logging seems to fail there.
Any suggestions or insights would be greatly appreciated. For context: I’m still relatively new to both FlexSim and C++.
Thanks in advance!
Environment details:
FlexSim version: 25.1
Build configuration: Release (x64)
Runtime library: Multi-threaded DLL (/MD) (also tested with /MT)
Exceptions: Enabled (/EHsc)
C++ standard: ISO C++20 (/std:c++20)
Platform Toolset: Visual Studio 2022 (v143)