Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenModelica cannot handle package constants coming from external functions in static libraries #54

Closed
casella opened this issue Feb 21, 2022 · 9 comments
Assignees

Comments

@casella
Copy link
Collaborator

casella commented Feb 21, 2022

Run ExternalMedia.Test.TestMedium.TestConstants with the latest nightly build of OpenModelica. The following error is generated:

[1] 20:08:32 Translation Error
[ExternalMedia.Media.BaseClasses.ExternalTwoPhaseMedium: 192:15-196:29]: External function ‘TwoPhaseMedium_getCriticalTemperature_C_impl‘ could not be found in any of the given shared libraries:
  C:/Program Files/OpenModelica1.19.0-dev-64bit/lib//omc/ExternalMediaLib.dll
  D:/Lavoro/Modelica/ExternalMedia 3.3.1/Resources/Library/win64/ExternalMediaLib.dll
  D:/Lavoro/Modelica/ExternalMedia 3.3.1/Resources/Library/ExternalMediaLib.dll

The reason for that is that the OpenModelica front-end tries to constant-evaluate the package constant Medium.externalFluidConstants.criticalTemperature at compile time during flattening. This constant is bound to the external function Medium.getCriticalTemperature(), which calls an external function to get the value from the external solver.

Recent improvements to version 1.19.0-dev of OpenModelica make it possible for the front-end to call such external functions, provided that they are available in dynamically linked/shared libraries. This will be addressed in #50.

@jowr
Copy link
Collaborator

jowr commented Feb 21, 2022 via email

@jowr
Copy link
Collaborator

jowr commented Feb 21, 2022 via email

@casella
Copy link
Collaborator Author

casella commented Feb 21, 2022

Please use the latest code. I think I fixed this already in 3.4.0 and in the 4.0.0 branch…

Will do.

@casella
Copy link
Collaborator Author

casella commented Feb 21, 2022

Wait - do you want to make the static library work with OM?

No, I don't care about that, since shared libraries are required to get the package constants working out of the box. I would also switch to shared libraries only for Dymola as well, so we can reduce the amount of binaries to generate, basically just one for each operating system.

Why are you asking that?

Wait - do you want to make the static library work with OM? Why did you change your mind? I thought we were pushing to get the shared lib running. On 21 Feb 2022, at 23.33, Jorrit Wronski @.> wrote:  Please use the latest code. I think I fixed this already in 3.4.0 and in the 4.0.0 branch… On 21 Feb 2022, at 22.57, Francesco Casella @.> wrote:  Run ExternalMedia.Test.TestMedium.TestConstants with the latest nightly build of OpenModelica. The following error is generated: [1] 20:08:32 Translation Error [ExternalMedia.Media.BaseClasses.ExternalTwoPhaseMedium: 192:15-196:29]: External function ‘TwoPhaseMedium_getCriticalTemperature_C_impl‘ could not be found in any of the given shared libraries: C:/Program Files/OpenModelica1.19.0-dev-64bit/lib//omc/ExternalMediaLib.dll D:/Lavoro/Modelica/ExternalMedia 3.3.1/Resources/Library/win64/ExternalMediaLib.dll D:/Lavoro/Modelica/ExternalMedia 3.3.1/Resources/Library/ExternalMediaLib.dll The reason for that is that the OpenModelica front-end tries to constant-evaluate the package constant Medium.externalFluidConstants.criticalTemperature at compile time during flattening. This constant is bound to the external function Medium.getCriticalTemperature(), which calls an external function to get the value from the external solver. Recent improvements to version 1.19.0-dev of OpenModelica make it possible for the front-end to call such external functions, provided that they are available in dynamically linked/shared libraries. This will be addressed in #50<#50>. — Reply to this email directly, view it on GitHub<#54>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAF34OKNJ36LFCVQ7GTEXSDU4KYLFANCNFSM5O7VUDEQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you are subscribed to this thread.Message ID: @.***>

@bilderbuchi
Copy link
Collaborator

bilderbuchi commented Feb 22, 2022

Why are you asking that?

I suspect because this issue's title talks about static libraries.

In any case, using the snapshot from #42 (comment) and OM v1.19.0-dev-613-gd6e04c0efc, I can compile and run ExternalMedia.Test.TestMedium.TestConstants without warnings.

However, compiling the WaterComparison model (#42), I get the exact same error (with a couple more paths mentioned). At the paths mentioned those dlls don't exist.

@casella
Copy link
Collaborator Author

casella commented Feb 22, 2022

Why are you asking that?

I suspect because this issue's title talks about static libraries.

Aha, now I get it. The issue is that OMC cannot handle static libraries. The cure can be either to have OMC handle them, or to avoid them entirely, and of course we want to take the second approach, as planned in #50.

@casella
Copy link
Collaborator Author

casella commented Feb 22, 2022

In any case, using the snapshot from #42 (comment) and OM v1.19.0-dev-613-gd6e04c0efc, I can compile and run ExternalMedia.Test.TestMedium.TestConstants without warnings.

Yes, @jowr mentioned that the dll's are actually built in the 4.0.0 branch. They won't handle errors correctly, and that's my part to implement.

However, compiling the WaterComparison model (#42), I get the exact same error (with a couple more paths mentioned). At the paths mentioned those dlls don't exist.

OK, as far as I can understand, omc is looking inside ExternalMedia 4.0.0/Resources/Library/ and inside ExternalMedia 4.0.0/Resources/Library/win64, but not inside ExternalMedia 4.0.0/Resources/Library/mingw64, which is where the .dll file is actually located. Sounds like an easy fix.

Would you mind opening a ticket that addresses this specific issue (and only this one!) with clear instructions to reproduce the problem? Please do that directly on OMC's issue tracker https://github.com/OpenModelica/OpenModelica/issues, and then I'll follow it up from there. We need to one ticket for each issue, othersiwe the whole thing becomes a bloody mess...

Thanks!

@bilderbuchi
Copy link
Collaborator

Sure thing, see OpenModelica/OpenModelica#8595

@casella
Copy link
Collaborator Author

casella commented May 20, 2022

This issue should now be fixed. As soon as #50 is finalized and OpenModelica #8995 are solved, ExternalMedia should work fine in OpenModelica as well.

@casella casella closed this as completed May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants