Opened 11 years ago

Closed 11 years ago

#2706 closed defect (fixed)

FMI export - dll dependency

Reported by: joohnycz Owned by: Adeel Asghar
Priority: high Milestone: 1.9.1
Component: FMI Version: trunk
Keywords: Cc: joohnycz@…

Description

I'm having trouble when using FMU exported from OpenModelica.

When I try to use the dll from FMU (function LoadLibrary), it fails with error 126 (maybe missing some module). When I try to open the dll with Dependency Walker, it reports dependency errors (see atachement). I guess there can be similarity with #2440.

OpenModelica 1.9.1 Beta2 (r19512), Win 8.1 32-bit, .NET 4.5, Win 8.1 SDK ...

Can someone please help me with this problem? Thanks

(and other tools export FMU with only one dll in win32 folder and it works without solving dll issues)

Attachments (1)

DependencyWalker.PNG (68.2 KB ) - added by joohnycz 11 years ago.

Download all attachments as: .zip

Change History (11)

by joohnycz, 11 years ago

Attachment: DependencyWalker.PNG added

comment:1 by Adrian Pop, 11 years ago

I suggest you try with the latest nightly build:
https://build.openmodelica.org/omc/builds/windows/nightly-builds/
as a lot of issues with FMUs have been fixed.

comment:2 by Adeel Asghar, 11 years ago

Use the sysinternals utility Process Monitor http://technet.microsoft.com/en-us/sysinternals/bb896645 from Microsoft to trace all file access while your dll is trying to load. With this utility, you will see everything that that dll is trying to pull in and usually the problem can be determined from there. Sometimes dependencywalker doesn't show the problem. Btw i can't see any serious problem in your dependency walker screenshot.

comment:3 by joohnycz, 11 years ago

Thanks.
Nightly build didnt help.
Using Process Monitor I found that quserex.dll is missing. When I downloaded one from net, LoadLibrary is OK, but I have some difficulties with passing arguments to FMU. Is this dll used by OpenModelica? Can someone provide me correct dll? I found that it is maybe related to MinGW.

in reply to:  3 ; comment:4 by Adeel Asghar, 11 years ago

Replying to joohnycz:

Thanks.
Nightly build didnt help.
Using Process Monitor I found that quserex.dll is missing. When I downloaded one from net, LoadLibrary is OK, but I have some difficulties with passing arguments to FMU. Is this dll used by OpenModelica? Can someone provide me correct dll? I found that it is maybe related to MinGW.

What do you mean by passing arguments? You need to dynamically load it and call the FMI interface functions.
I suppose you have the correct dll if it is produced using

translateModelFMU

Yes the dll is compiled using MinGW.

comment:5 by Adrian Pop, 11 years ago

Hm, very strange. I searched for quserex.dll on my machine and is not present.
As we don't specifically link with it, do you know which library wants to load it so we can do some debugging?

in reply to:  4 ; comment:6 by joohnycz, 11 years ago

Sorry for my late reply. Today I managed to solve the problem.

First problem was loading dlls on which the simulation is dependent and are provided inside FMU (I had to copy them into searched folder or search them in FMU's folder).

And the second problem: I tested the FMU from OpenModelica, which is only gain, so it has no continuous state. When I called fmiGetContinuousStates, FMU reported "Invalid argument" as you can see in code below. Because of unreadable log I didn't realize that problem might be in calling fmiGetContinuousStates in FMU without continuous states (in FMUs from other tools it is not problem, I've tested it).

Replying to adeas31:

What do you mean by passing arguments? You need to dynamically load it and call the FMI interface functions.

I meant passing arguments when calling interface functions as you mentioned (according to FMI standard). I found that invalid argument was one of fmiGetContinuousStates arguments (x or nx).

Sun Jun 01 12:27:34 2014
 0 OM_night log fmiSetTime: time=%.16g
Sun Jun 01 12:27:34 2014
 0  log fmiSetReal: nvr = %d
Sun Jun 01 12:27:34 2014
 0  log fmiSetReal: #r%d# = %.16g
Sun Jun 01 12:27:34 2014
 0 Ŕa) < log fmiInitialize: toleranceControlled=%d relativeTolerance=%g
Sun Jun 01 12:27:34 2014
 0 Ŕa) < log fmiInitialization: succeed
Sun Jun 01 12:27:34 2014
 3 €c) < error %s: Invalid argument %s = NULL.
Sun Jun 01 12:27:34 2014
 0 €c) < log fmiFreeModelInstance

So now I can simulate FMU from OpenModelica, but there is problem with passing fmiStrings to logger - maybe at my side, I don't know yet (but logger works well with FMUs exported by other tools like CATIA, Dymola ...).

I found that problems with logger can be caused by imperfection in function fmiComponent fmiInstantiateModel (...) (function probably doesn't copy instanceName)

Log from FMU Compliance Checker

[VERBOSE][FMICAPI] Calling fmiInitialize
[ERROR][FMUCHK] FMU does not make an internal copy of provided instance name (violation of fmiString handling)
	[FMU][log][FMU status:OK] fmiInitialize: toleranceControlled=0 relativeTolerance=1e-006
	[FMU][log][FMU status:OK] fmiInitialization: succeed

And BTW there is another error with memory

[ERROR][FMUCHK] Memory leak: freeMemory was not called for 1 block(s) allocated by allocateMemory

Thanks

in reply to:  5 comment:7 by joohnycz, 11 years ago

Replying to adrpo:

Hm, very strange. I searched for quserex.dll on my machine and is not present.
As we don't specifically link with it, do you know which library wants to load it so we can do some debugging?

I found that the result is the same when the quserex.dll is missing and when quserex.dll is present. And I found that dll is searched only in directory C:\Windows\system32 (in contrast with loading other dlls, which are searched in multiple directories, like C:\Windows\system32, C:\Windows, C:\Windows\system). And when I simulate FMU in OpenModelica, the dll is also searched (and not found) and the simulation is successful.

So maybe the quserex.dll isn't important for simulation of FMUs. But this dll is searched only when simulating FMU's exported from OpenModelica (the dll isn't called by my SW nor by FMUs from other tools).

Unfourtunately I can't detect which library tries to use it, but I think it can be libgfortran-3.dll (it is used just before attempt to load quserex.dll).

in reply to:  6 ; comment:8 by Adeel Asghar, 11 years ago

Replying to joohnycz:

I found that problems with logger can be caused by imperfection in function fmiComponent fmiInstantiateModel (...) (function probably doesn't copy instanceName)

Log from FMU Compliance Checker

[VERBOSE][FMICAPI] Calling fmiInitialize
[ERROR][FMUCHK] FMU does not make an internal copy of provided instance name (violation of fmiString handling)
	[FMU][log][FMU status:OK] fmiInitialize: toleranceControlled=0 relativeTolerance=1e-006
	[FMU][log][FMU status:OK] fmiInitialization: succeed

And BTW there is another error with memory

[ERROR][FMUCHK] Memory leak: freeMemory was not called for 1 block(s) allocated by allocateMemory

Thanks

I fixed the errors shown in FMU Compliance Checker in r20915.

in reply to:  8 comment:9 by joohnycz, 11 years ago

I fixed the errors shown in FMU Compliance Checker in r20915.

It works great, thanks a lot.

comment:10 by Adeel Asghar, 11 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.