#5035 closed defect (fixed)
FMI export produces non-FMI-compliant FMUs
Reported by: | Owned by: | Lennart Ochel | |
---|---|---|---|
Priority: | high | Milestone: | 1.13.0 |
Component: | FMI | Version: | v1.12.0 |
Keywords: | Cc: | henning.larsson@…, mathias.strandberg@… |
Description
Hi, OpenModelica.
We have been trying to import FMUs created with OpenModelica FMU export with FMI Toolbox for MatLab/Simulink as well as Dymola and it does not work.
We think that some part of the FMU-export in OpenModelica is not compliant with the FMI-standard as the error message from Matlab:
module = FMICAPI, log level = FATAL: Could not load the DLL: The specified procedure could not be found.
Error:Error reported by S-function 'XXXX' in 'model_name/fmu_name':
Could not load the DLL. See the Command Window for more details.
Suggests that the OpenModelica FMU has a dynamic dependency on the Windows C runtime. This is not compliant with the FMI 2.0 standard, which states
"Dynamic link
libraries must include all referenced resources that are not available on a standard target machine [for
example DLLs on Windows machines must be built with option “MT” to include the run-time environment
of VisualStudio in the DLL, and not use the option “MD” where this is not the case]" (p. 66)
Is this something you have seen before?
Let me know if you need more information.
/Marcus Åberg, Modelon AB
Attachments (3)
Change History (24)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
I will reply in the ticket to keep trac of this.
If you compiled on the same machine I find it rather strange
that it doesn't work as it should be linked with the version
of the msvcrt.dll present on that machine.
This means that Matlab and Dymola is using some different
version of msvcrt.dll? I would find that strange so the
problem probably lies someplace else.
You get: "Could not load the DLL: The specified procedure could not be found."
Can you get more information on which function cannot be found in the dll and which dll is that?
comment:3 by , 6 years ago
Reply from Marcus via email:
I got the following error message when trying to simulate the model with the FMU in Simulink:
"MATLAB.exe - Entry Point Not Found
The procedure entry point _ZNKSt7cxx1112basic_stringlcSt11char_traitslcESalcEE4findEPKcyy could not be located in the dynamic link library C:\Users\-------\AppData\Local\Temp\fmu\tp794a81d8_118b_4b16_94fc_4575a3cc34b3\binaries\win64\fmi_name.dll"
I do not know however if that is useful information for you?
I could not find any reference to what .dll file matlab could not load from the log in matlab.
comment:4 by , 6 years ago
Ok, it does help, it seems that the process has already loaded some other libstdc++.dll which is different than the one provided by us in the binary folder.
I will try to change the FMU generation in 1.13 to link listdc++ statically if possible.
Questions:
- fmi_name.dll is the FMU generated by OpenModelica?
- what runtime are you using to generate the FMU? C runtime or C++ runtime?
by , 6 years ago
Attachment: | Modelica_Mechanics_MultiBody_Examples_Elementary_DoublePendulum.fmu added |
---|
comment:5 by , 6 years ago
To answer your questions:
- Yes it is.
- I don't know how can i check? I attached an fmu that i get this problem with.
by , 6 years ago
Attachment: | Modelica_Mechanics_MultiBody_Examples_Elementary_DoublePendulum.2.fmu added |
---|
FMU compiled with -static-libgcc -static-libstdc++
comment:7 by , 6 years ago
I compiled the attached FMU with static flags for libgcc and stc++, see if this one works for you.
comment:8 by , 6 years ago
I'm sorry Matlab crashes when i try to simulate your FMU.
MATLAB crash file:C:\Users\MARCUS~1.ABE\AppData\Local\Temp\matlab_crash_dump.11980-1:
Access violation detected at Thu Jul 5 17:59:16 2018
Configuration:
Crash Decoding : Disabled - No sandbox or build area path
Crash Mode : continue (default)
Current Graphics Driver: Intel Intel(R) HD Graphics 520 Version 4.5.0 - Build 22.20.16.4799
Default Encoding : windows-1252
Deployed : false
Graphics card 1 : Intel Corporation ( 0x8086 ) Intel(R) HD Graphics 520 Version 22.20.16.4799 (2017-9-14)
Host Name : DESKTOP-9PTCRCG
MATLAB Architecture : win64
MATLAB Entitlement ID: 1851340
MATLAB Root : C:\Program Files\MATLAB\R2017b
MATLAB Version : 9.3.0.713579 (R2017b)
OpenGL : hardware
Operating System : Microsoft Windows 10 Pro
Processor ID : x86 Family 6 Model 78 Stepping 3, GenuineIntel
Virtual Machine : Java 1.8.0_121-b13 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
Window System : Version 10.0 (Build 17134)
Fault Count: 1
Abnormal termination:
Access violation
Register State (from fault):
RAX = 0000000028103d60 RBX = 0000000000000000
RCX = 00000000c1427720 RDX = 00000000c143f1c0
RSP = 00000000043f79e8 RBP = 0000000000000000
RSI = 0000000000000000 RDI = 00000000c1427720
R8 = 00000001fdee2ee0 R9 = 0000000000000010
R10 = 0000000028103bf0 R11 = 0000000000000000
R12 = 0000000000000371 R13 = 0000000000000001
R14 = 00000001fdee2ee0 R15 = 00000001fdee2f60
RIP = 0000000000000000 EFL = 00010202
CS = 0033 FS = 0053 GS = 002b
Stack Trace (from fault):
[ 0] 0x0000000000000000 <unknown-module>+00000000
[ 1] 0x00000001fcf9e7d5 C:\Users\MARCUS~1.ABE\AppData\Local\Temp\fmu\tp58ec5935_96bc_4130_9fc2_b39ce7aed974\binaries\win64\Modelica_Mechanics_MultiBody_Examples_Elementary_DoublePendulum.dll+01042389 mmc_init+00000709
[ 2] 0x00000001fcea2901 C:\Users\MARCUS~1.ABE\AppData\Local\Temp\fmu\tp58ec5935_96bc_4130_9fc2_b39ce7aed974\binaries\win64\Modelica_Mechanics_MultiBody_Examples_Elementary_DoublePendulum.dll+00010497 fmi2Instantiate+00001169
[ 3] 0x000000012fee0c67 C:\Program Files (x86)\Modelon\FMI Toolbox 2.6.3\fmitoolbox\sfun_fmu_me_1_0_2_0.mexw64+00134247 mexFunction+00089703
[ 4] 0x000000012fed6d0e C:\Program Files (x86)\Modelon\FMI Toolbox 2.6.3\fmitoolbox\sfun_fmu_me_1_0_2_0.mexw64+00093454 mexFunction+00048910
[ 5] 0x000000012fec4022 C:\Program Files (x86)\Modelon\FMI Toolbox 2.6.3\fmitoolbox\sfun_fmu_me_1_0_2_0.mexw64+00016418
[ 6] 0x000000012fed4993 C:\Program Files (x86)\Modelon\FMI Toolbox 2.6.3\fmitoolbox\sfun_fmu_me_1_0_2_0.mexw64+00084371 mexFunction+00039827
[ 7] 0x000000012fec212e C:\Program Files (x86)\Modelon\FMI Toolbox 2.6.3\fmitoolbox\sfun_fmu_me_1_0_2_0.mexw64+00008494
[ 8] 0x000000012fec9a4c C:\Program Files (x86)\Modelon\FMI Toolbox 2.6.3\fmitoolbox\sfun_fmu_me_1_0_2_0.mexw64+00039500
[ 9] 0x00000000fc60234a bin\win64\libmex.dll+00140106 mexRunMexFile+00000314
[ 10] 0x00000000fc600d22 bin\win64\libmex.dll+00134434 mexFeature_mexver+00002146
[ 11] 0x00000000fc5ffab7 bin\win64\libmex.dll+00129719 mexUnlock+00028455
[ 12] 0x000000001960ca93 bin\win64\pgo\m_dispatcher.dll+00117395 Mfh_file::dispatch_fh_impl+00000835
[ 13] 0x000000001960c73e bin\win64\pgo\m_dispatcher.dll+00116542 Mfh_file::dispatch_fh+00000062
[ 14] 0x0000000019658f83 bin\win64\pgo\m_dispatcher.dll+00429955 mdAcquireMatlabFunction+00000279
[ 15] 0x00000000196593d4 bin\win64\pgo\m_dispatcher.dll+00431060 mdDoMatlabFcnCall+00000116
[ 16] 0x00000000d088e31a bin\win64\sl_utility.dll+00320282 SimpleUserException::~SimpleUserException+00000138
[ 17] 0x00000000d048f948 bin\win64\libmwsl_services.dll+01112392 CMatlabCommandNoWatermark::execute+00000056
[ 18] 0x00000000d088ec29 bin\win64\sl_utility.dll+00322601 slDoMatlabFcnCall+00000089
[ 19] 0x000000015b1fa367 bin\win64\libmwsimulink.dll+18654055 SlCoderDataClient::getCoderDataTypeMap+00060583
[ 20] 0x000000015b1ea31a bin\win64\libmwsimulink.dll+18588442 SLGlue::isParamOwnerBlock+00000138
[ 21] 0x000000015b1ea190 bin\win64\libmwsimulink.dll+18588048 slSetStateflowChartStateAccessInterface+00018064
[ 22] 0x000000015afda73a bin\win64\libmwsimulink.dll+16426810 BlockSetLocation+00000634
[ 23] 0x000000015a87f0d8 bin\win64\libmwsimulink.dll+08712408 PartitionSort::Partition::setLoopID+00023672
[ 24] 0x000000015a973bfc bin\win64\libmwsimulink.dll+09714684 sl::InterfaceDisplayJob::createUnitsUpdateJob+00176524
[ 25] 0x000000015a99859b bin\win64\libmwsimulink.dll+09864603 sl::InterfaceDisplayJob::createUnitsUpdateJob+00326443
[ 26] 0x000000015b247a18 bin\win64\libmwsimulink.dll+18971160 slstSetOutputPortRateID+00086360
[ 27] 0x000000015b24c44d bin\win64\libmwsimulink.dll+18990157 SLGlue::PortSignalGenerator::isEmpty+00011405
[ 28] 0x000000015b251771 bin\win64\libmwsimulink.dll+19011441 SLGlue::PortSignalGenerator::isEmpty+00032689
[ 29] 0x000000015b288fd0 bin\win64\libmwsimulink.dll+19238864 SLGlue::PortSignalGenerator::isEmpty+00260112
[ 30] 0x000000015a2be59b bin\win64\libmwsimulink.dll+02680219 ExitPauseInDebuggerMenuSim+00002155
[ 31] 0x000000015ad3ca88 bin\win64\libmwsimulink.dll+13683336 SLGlue::simulationStartPauseContinue+00000296
[ 32] 0x000000012fc06d26 bin\win64\sl_mi.dll+00290086 SLM3I::mi::initCosSFBlockOpenNotification+00037446
[ 33] 0x0000000022d2705d bin\win64\pgo\mcos_impl.dll+00553053
[ 34] 0x0000000022d26848 bin\win64\pgo\mcos_impl.dll+00550984
[ 35] 0x0000000022cf524d bin\win64\pgo\mcos_impl.dll+00348749
[ 36] 0x0000000022cf4b80 bin\win64\pgo\mcos_impl.dll+00347008
[ 37] 0x0000000022cf5de5 bin\win64\pgo\mcos_impl.dll+00351717
[ 38] 0x0000000022cf6f4e bin\win64\pgo\mcos_impl.dll+00356174
[ 39] 0x00000000195f8f74 bin\win64\pgo\m_dispatcher.dll+00036724 Mfh_MATLAB_fn::dispatch_fh+00000660
[ 40] 0x0000000022cf3ab0 bin\win64\pgo\mcos_impl.dll+00342704
[ 41] 0x000000001a30526f bin\win64\pgo\m_lxe.dll+01069679 boost::serialization::singleton<boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree> >::get_instance+00612523
[ 42] 0x000000001a231c14 bin\win64\pgo\m_lxe.dll+00203796
[ 43] 0x00000000109c1f48 bin\win64\pgo\libmx.dll+00532296 matrix::detail::noninlined::mx_array_api::mxFevalFunctionHandle+00000036
[ 44] 0x000000001972ea9a bin\win64\pgo\m_interpreter.dll+00256666 inRegisterMFunctionFromOpaqueArray+00052422
[ 45] 0x000000001960d42e bin\win64\pgo\m_dispatcher.dll+00119854 mdPathNotification::function_rebind_notification+00000158
[ 46] 0x00000000195f8f74 bin\win64\pgo\m_dispatcher.dll+00036724 Mfh_MATLAB_fn::dispatch_fh+00000660
[ 47] 0x000000001a30526f bin\win64\pgo\m_lxe.dll+01069679 boost::serialization::singleton<boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree> >::get_instance+00612523
[ 48] 0x000000001a29a767 bin\win64\pgo\m_lxe.dll+00632679 boost::serialization::singleton<boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree> >::get_instance+00175523
[ 49] 0x000000001a2973a1 bin\win64\pgo\m_lxe.dll+00619425 boost::serialization::singleton<boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree> >::get_instance+00162269
[ 50] 0x00000000196f9f17 bin\win64\pgo\m_interpreter.dll+00040727 inCallFcn+00000119
[ 51] 0x000000001a297292 bin\win64\pgo\m_lxe.dll+00619154 boost::serialization::singleton<boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree> >::get_instance+00161998
[ 52] 0x00000000197028cf bin\win64\pgo\m_interpreter.dll+00075983 inCallFcnWithTrap+00000095
[ 53] 0x00000000ce7515ac bin\win64\dastudio.dll+03610028 SafeCallMatlab+00000204
[ 54] 0x00000000ce742c06 bin\win64\dastudio.dll+03550214 ActionSchema::invokeCallback+00000134
[ 55] 0x00000000ce74b60e bin\win64\dastudio.dll+03585550 DigCallbackInvoker::invokeUDI+00000766
[ 56] 0x00000000ce74b2ea bin\win64\dastudio.dll+03584746 DigDefaultCallbackInvoker::invoke+00000058
[ 57] 0x00000000ce7d5a00 bin\win64\dastudio.dll+04151808 DeferredManager::get_instance+00000080
[ 58] 0x00000000ce5446aa bin\win64\dastudio.dll+01459882 DAWidgetInterface::getMClass+00033882
[ 59] 0x00000000ce5557bc bin\win64\dastudio.dll+01529788 DAWidgetInterface::getMClass+00103788
[ 60] 0x00000000ce53d8cf bin\win64\dastudio.dll+01431759 DAWidgetInterface::getMClass+00005759
[ 61] 0x00000000ce544666 bin\win64\dastudio.dll+01459814 DAWidgetInterface::getMClass+00033814
[ 62] 0x00000000ce53ecf3 bin\win64\dastudio.dll+01436915 DAWidgetInterface::getMClass+00010915
[ 63] 0x00000000ce558da6 bin\win64\dastudio.dll+01543590 DAWidgetInterface::getMClass+00117590
[ 64] 0x00000000fd0080f7 bin\win64\iqm.dll+00491767 iqm::PackagedTaskPlugin::PackagedTaskPlugin+00000759
[ 65] 0x00000000fd0088bf bin\win64\iqm.dll+00493759 iqm::PackagedTaskPlugin::execute+00000879
[ 66] 0x00000000fd00817d bin\win64\iqm.dll+00491901 iqm::PackagedTaskPlugin::PackagedTaskPlugin+00000893
[ 67] 0x00000000fd008708 bin\win64\iqm.dll+00493320 iqm::PackagedTaskPlugin::execute+00000440
[ 68] 0x0000000019435651 bin\win64\mcr.dll+00349777 OnlineLicenseManagementLauncher::~OnlineLicenseManagementLauncher+00010049
[ 69] 0x00000000fcfdbd3a bin\win64\iqm.dll+00310586 iqm::Iqm::setupIqmFcnPtrs+00079802
[ 70] 0x00000000fcfdbc06 bin\win64\iqm.dll+00310278 iqm::Iqm::setupIqmFcnPtrs+00079494
[ 71] 0x00000000fcfbeb65 bin\win64\iqm.dll+00191333 iqm::Iqm::deliver+00001397
[ 72] 0x00000000fb5fd3c3 bin\win64\libmwbridge.dll+00054211 ioReadLine+00000547
[ 73] 0x00000000fb5fd262 bin\win64\libmwbridge.dll+00053858 ioReadLine+00000194
[ 74] 0x00000000fb60d7de bin\win64\libmwbridge.dll+00120798 mnDebugPrompt+00001966
[ 75] 0x00000000fb60d170 bin\win64\libmwbridge.dll+00119152 mnDebugPrompt+00000320
[ 76] 0x00000000fb60db63 bin\win64\libmwbridge.dll+00121699 mnParser+00000547
[ 77] 0x000000001941bdb1 bin\win64\mcr.dll+00245169 mcr::runtime::setInterpreterThreadSingletonToCurrent+00029793
[ 78] 0x000000001941ace5 bin\win64\mcr.dll+00240869 mcr::runtime::setInterpreterThreadSingletonToCurrent+00025493
[ 79] 0x000000001941ad53 bin\win64\mcr.dll+00240979 mcr::runtime::setInterpreterThreadSingletonToCurrent+00025603
[ 80] 0x000000001941b6e1 bin\win64\mcr.dll+00243425 mcr::runtime::setInterpreterThreadSingletonToCurrent+00028049
[ 81] 0x00000000fd02cc77 bin\win64\iqm.dll+00642167 iqm::UserEvalPlugin::pre+00028951
[ 82] 0x00000000fd039cfc bin\win64\iqm.dll+00695548 iqm::UserEvalPlugin::pre+00082332
[ 83] 0x00000000fd02737f bin\win64\iqm.dll+00619391 iqm::UserEvalPlugin::pre+00006175
[ 84] 0x00000000fd02cc16 bin\win64\iqm.dll+00642070 iqm::UserEvalPlugin::pre+00028854
[ 85] 0x00000000fd027863 bin\win64\iqm.dll+00620643 iqm::UserEvalPlugin::pre+00007427
[ 86] 0x00000000fd03c8b6 bin\win64\iqm.dll+00706742 iqm::UserEvalPlugin::pre+00093526
[ 87] 0x00000000fd0080f7 bin\win64\iqm.dll+00491767 iqm::PackagedTaskPlugin::PackagedTaskPlugin+00000759
[ 88] 0x00000000fd0088bf bin\win64\iqm.dll+00493759 iqm::PackagedTaskPlugin::execute+00000879
[ 89] 0x00000000fd00817d bin\win64\iqm.dll+00491901 iqm::PackagedTaskPlugin::PackagedTaskPlugin+00000893
[ 90] 0x00000000fd008708 bin\win64\iqm.dll+00493320 iqm::PackagedTaskPlugin::execute+00000440
[ 91] 0x00000000fcfdbd3a bin\win64\iqm.dll+00310586 iqm::Iqm::setupIqmFcnPtrs+00079802
[ 92] 0x00000000fcfdbc06 bin\win64\iqm.dll+00310278 iqm::Iqm::setupIqmFcnPtrs+00079494
[ 93] 0x00000000fcfbf5be bin\win64\iqm.dll+00193982 iqm::Iqm::deliver+00004046
[ 94] 0x00000000fcfc0545 bin\win64\iqm.dll+00197957 iqm::Iqm::deliver+00008021
[ 95] 0x00000001001237c1 bin\win64\libmwservices.dll+01259457 services::system_events::PpeDispatchHook::dispatchOne+00021505
[ 96] 0x0000000100128663 bin\win64\libmwservices.dll+01279587 sysq::addProcessPendingEventsUnitTestHook+00002211
[ 97] 0x0000000100128850 bin\win64\libmwservices.dll+01280080 sysq::addProcessPendingEventsUnitTestHook+00002704
[ 98] 0x0000000100129c26 bin\win64\libmwservices.dll+01285158 sysq::getCondition+00003462
[ 99] 0x000000010012ac66 bin\win64\libmwservices.dll+01289318 svWS_ProcessPendingEvents+00000230
[100] 0x000000001941c244 bin\win64\mcr.dll+00246340 mcr::runtime::setInterpreterThreadSingletonToCurrent+00030964
[101] 0x000000001941c964 bin\win64\mcr.dll+00248164 mcr::runtime::setInterpreterThreadSingletonToCurrent+00032788
[102] 0x0000000019412762 bin\win64\mcr.dll+00206690 mcr_process_events+00008818
[103] 0x00000000193523c5 bin\win64\MVMLocal.dll+00271301 mvm_server::inproc::LocalFactory::terminate+00088005
[104] 0x00000000fa957669 bin\win64\mvm.dll+01209961 mvm::detail::initLocalMvmHack+00000569
[105] 0x00000000fa957e2b bin\win64\mvm.dll+01211947 mvm::detail::SessionImpl::privateSession+00000555
[106] 0x00000000fa958051 bin\win64\mvm.dll+01212497 mvm::detail::SessionImpl::privateSession+00001105
[107] 0x0000000140007833 bin\win64\MATLAB.exe+00030771
[108] 0x000000014000863f bin\win64\MATLAB.exe+00034367
[109] 0x00007ffe07c03034 C:\WINDOWS\System32\KERNEL32.DLL+00077876 BaseThreadInitThunk+00000020
[110] 0x00007ffe0a201431 C:\WINDOWS\SYSTEM32\ntdll.dll+00463921 RtlUserThreadStart+00000033
This error was detected while a MEX-file was running. If the MEX-file
is not an official MathWorks function, please examine its source code
for errors. Please consult the External Interfaces Guide for information
on debugging MEX-files.
If this problem is reproducible, please submit a Service Request via:
A technical support engineer might contact you with further information.
Thank you for your help.
comment:9 by , 6 years ago
OK. At least now it loads the dll, so a problem is fixed. On to the next one. I'll have a look in the code what dies.
by , 6 years ago
Attachment: | Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum.fmu added |
---|
this one only depends on: kernel32.dll, msvcrt.dll, user32.dll
comment:12 by , 6 years ago
Yes, now it works fine!
Thank you for your quick response. Is this a fix for the fmu export you intend to include in a future release of OpenModelica or what does the road map look like now?
/Marcus
comment:13 by , 6 years ago
This was already pushed to master, see PR 2568, so it is already available in the nightly builds of 1.13.0-dev and will eventually be included in the forthcoming 1.13.0 release.
comment:14 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:15 by , 6 years ago
Milestone: | Future → 1.13.0 |
---|
comment:16 by , 6 years ago
Not yet in the nightly-builds, but soon enough, I just started the Hudson job to build them.
comment:19 by , 6 years ago
Unfortunately is not over yet, I broke some other stuff, I'll fix it and restart the builds again.
comment:20 by , 6 years ago
Ok. I fixed the introduced problems. You can use this build to test more:
https://build.openmodelica.org/omc/builds/windows/nightly-builds/64bit/
We don't use Visual Studio in OpenModelica but mingw64/32 which unfortunately does not have a static version of the runtime available. We could probably include the runtime system inside the binaries folder but is not certain the process that loads the FMU will use that one, especially if it already loaded the other one.
Did you create the FMU on the same machine in which you are trying to use it?