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

Compiling ExternalMedia for OMC now #9

Closed
casella opened this issue Nov 23, 2017 · 6 comments
Closed

Compiling ExternalMedia for OMC now #9

casella opened this issue Nov 23, 2017 · 6 comments

Comments

@casella
Copy link
Collaborator

casella commented Nov 23, 2017

@JonWel, @jowr, I have some requests by people who need to run the library right away on OMC, but are running into trouble with the released 3.2.1. I also verified myself that it doesn't work, possibly because something was broken in the OMC code generation since when I compiled for 3.2.1 in 2015, as I get gcc complaining about undefined symbols in the C code when trying to run some examples in the library.

One option is to try to fix 3.2.1, but I wonder if it would make more sense to compile what we have now on v.3.3.0-dev. Was the library tested and deployable with OMC when you stopped developing coolprop/ExternalMedia in 2016? What do you suggest?

Thanks!

@JonWel
Copy link
Contributor

JonWel commented Nov 23, 2017

Hi,

I never tested to use it with OMC.
When I worked on this project, I understood it was only working with Dymola, but that it would be nice if it could be ported to OpenModelica in some maybe future projects.

In term of things that changed, as I focussed on the C++ code and I don't think I introduce much changes that could brake the possibility to use OMC.
So if I had to decide, I would go for 3.3.0-dev, in order to do the work only once.

@jowr will probably have a more enlighten view on this issue.

@jacquemoud
Copy link

Could you eventually test to import the Externalmedia Library into OMC just to share your experience?
https://build.openmodelica.org/omc/builds/windows/releases/1.12/final/
From my poor experience sofar, the 32-bit Version digest better the compilation of the Test cases.
However not everything is working well with the Coolprop, Refprop linkage...

Many Thanks

@slamer59
Copy link

slamer59 commented Jan 12, 2018

Hello,
I'm trying to build ExternalMedia with OMC.
I experienced some problem.

Here is my step:

git clone https://github.com/slamer59/ExternalMedia.git ExternalMedia-fork
cd ExternalMedia-fork/
git pull origin v.3.3.0-dev
cd Projects
chmod 755 BuildLib-CMake.sh
./BuildLib-CMake.sh

I change a little this script to:

  • add a variable pointing to cmake 3 version. I had cmake 2.8 with CMP0053 Policy warning wich raise an error at the end.
  • FLUIDP=0

And experienced this problem for Main dependencies and related to CoolProp::REFOPROP:

Scanning dependencies of target main
[ 86%] Building CXX object CMakeFiles/main.dir/Tests/coolprop_comparisons.cpp.o
[ 88%] Building CXX object CMakeFiles/main.dir/Sources/basesolver.cpp.o
[ 89%] Building CXX object CMakeFiles/main.dir/Sources/coolpropsolver.cpp.o
[ 91%] Building CXX object CMakeFiles/main.dir/Sources/errorhandling.cpp.o
[ 93%] Building CXX object CMakeFiles/main.dir/Sources/externalmedialib.cpp.o
[ 94%] Building CXX object CMakeFiles/main.dir/Sources/mingw_gcc_comutil.cpp.o
[ 96%] Building CXX object CMakeFiles/main.dir/Sources/solvermap.cpp.o
[ 98%] Building CXX object CMakeFiles/main.dir/Sources/testsolver.cpp.o
[100%] Linking CXX executable main
CoolProp/CMakeFiles/CoolProp.dir/src/Backends/REFPROP/REFPROPMixtureBackend.cpp.o: In function `getFunctionPointer(char const*, DLLNameManglingStyle)':
REFPROPMixtureBackend.cpp:(.text+0x2d5): undefined reference to `dlsym'
CoolProp/CMakeFiles/CoolProp.dir/src/Backends/REFPROP/REFPROPMixtureBackend.cpp.o: In function `load_REFPROP(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
REFPROPMixtureBackend.cpp:(.text+0xfe6): undefined reference to `dlopen'
REFPROPMixtureBackend.cpp:(.text+0x1030): undefined reference to `dlerror'
CoolProp/CMakeFiles/CoolProp.dir/src/Backends/REFPROP/REFPROPMixtureBackend.cpp.o: In function `unload_REFPROP(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
REFPROPMixtureBackend.cpp:(.text+0x1310): undefined reference to `dlclose'
REFPROPMixtureBackend.cpp:(.text+0x1326): undefined reference to `dlerror'
CoolProp/CMakeFiles/CoolProp.dir/src/Backends/REFPROP/REFPROPMixtureBackend.cpp.o: In function `CoolProp::REFPROPMixtureBackend::~REFPROPMixtureBackend()':
REFPROPMixtureBackend.cpp:(.text+0x1f17): undefined reference to `dlclose'
collect2: ld a retourné 1 code d'état d'exécution
gmake[2]: *** [main] Erreur 1
gmake[1]: *** [CMakeFiles/main.dir/all] Erreur 2
gmake: *** [all] Erreur 2

Do you have an idea ? I think I should deactivate something because libExternalMediaLib.a seems already build ?

**Version Info ** :

-- ExternalMedia library version: 3.2.1
-- COOLPROP_INSTALL_PREFIX=/home/thomas.pedot/Sources-Logiciels/Modelica/ExternalMedia-fork/externals/CoolProp.git/install_root
-- CoolProp version: 6.1.1dev
-- Setting bitness flag -m64
-- Library compilation detected:
-- Creating CoolProp, a 64-bit library
-- CMAKE_SYSTEM_NAME: Linux
-- COOLPROP_STATIC_LIBRARY: OFF
-- COOLPROP_SHARED_LIBRARY: OFF
-- COOLPROP_OBJECT_LIBRARY: ON
-- CONVENTION:
-- COOLPROP_LIBRARY_HEADER:
-- COOLPROP_LIBRARY_SOURCE:
-- COMPILE_FLAGS:  -m64
-- LINK_FLAGS:  -m64
-- Configuring done
-- Generating done

with:

OMEdit 1.13.0~dev
Connected to OpenModelica 1.13.0~dev

I will try with a 32bits version as suggested.

Regards

@slamer59
Copy link

I fail to compile ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical

/opt/rh/devtoolset-4/root/usr/bin/gcc -fopenmp   -fPIC -O0 -falign-functions -march=native  -fopenmp    "-I/home/thomas.pedot/Sources-Logiciels/Modelica/ExternalMedia-fork/Modelica/ExternalMedia 3.2.1/Resources/Include" -I"/opt/openmodelica-nightly/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0  -c -o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_17inl.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_17inl.c
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c: In function 'omc_ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_Medium_setState__pT':
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:85:53: warning: passing argument 3 of 'TwoPhaseMedium_setState_pT_C_impl' from incompatible pointer type [-Wincompatible-pointer-types]
   TwoPhaseMedium_setState_pT_C_impl(_p_ext, _T_ext, &_state_ext, MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp1)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp2)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp3)));
                                                     ^
In file included from ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_includes.h:4:0,
                 from ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:6:
/home/thomas.pedot/Sources-Logiciels/Modelica/ExternalMedia-fork/Modelica/ExternalMedia 3.2.1/Resources/Include/externalmedialib.h:144:14: note: expected 'ExternalThermodynamicState * {aka struct <anonymous> *}' but argument is of type 'ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_Medium_ThermodynamicState * {aka struct ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_Medium_ThermodynamicState_s *}'
  EXPORT void TwoPhaseMedium_setState_pT_C_impl(double p, double T, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
              ^
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c: In function 'omc_ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_Medium_setState__ph':
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:133:65: warning: passing argument 4 of 'TwoPhaseMedium_setState_ph_C_impl' from incompatible pointer type [-Wincompatible-pointer-types]
   TwoPhaseMedium_setState_ph_C_impl(_p_ext, _h_ext, _phase_ext, &_state_ext, MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp1)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp2)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp3)));
                                                                 ^
In file included from ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_includes.h:4:0,
                 from ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:6:
/home/thomas.pedot/Sources-Logiciels/Modelica/ExternalMedia-fork/Modelica/ExternalMedia 3.2.1/Resources/Include/externalmedialib.h:143:14: note: expected 'ExternalThermodynamicState * {aka struct <anonymous> *}' but argument is of type 'ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_Medium_ThermodynamicState * {aka struct ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_Medium_ThermodynamicState_s *}'
  EXPORT void TwoPhaseMedium_setState_ph_C_impl(double p, double h, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
              ^
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c: In function 'omc_ExternalMedia_Test_GenericModels_CompleteThermodynamicState$completeState1_Medium_molarMass':
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:238:138: error: '_fluidConstants' undeclared (first use in this function)
   _MM = ((ExternalMedia_Test_GenericModels_CompleteThermodynamicState$completeState1_Medium_FluidConstants*)(generic_array_element_addr(&_fluidConstants, sizeof(ExternalMedia_Test_GenericModels_CompleteThermodynamicState$completeState1_Medium_FluidConstants), 1, /* modelica_integer */ ((modelica_integer) 1))))->_molarMass;
                                                                                                                                          ^
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:238:138: note: each undeclared identifier is reported only once for each function it appears in
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c: In function 'omc_ExternalMedia_Test_GenericModels_CompleteThermodynamicState$completeState2_Medium_molarMass':
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:383:138: error: '_fluidConstants' undeclared (first use in this function)
   _MM = ((ExternalMedia_Test_GenericModels_CompleteThermodynamicState$completeState2_Medium_FluidConstants*)(generic_array_element_addr(&_fluidConstants, sizeof(ExternalMedia_Test_GenericModels_CompleteThermodynamicState$completeState2_Medium_FluidConstants), 1, /* modelica_integer */ ((modelica_integer) 1))))->_molarMass;
                                                                                                                                          ^
make: *** [ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.o] Error 1
make: *** Waiting for unfinished jobs....
Compilation process failed. Exited with code 2.

There is some like warning warning: passing argument 3 of 'TwoPhaseMedium_setState_pT_C_impl' from incompatible pointer type [-Wincompatible-pointer-types]

@JonWel
Copy link
Contributor

JonWel commented Jan 12, 2018

Hi @slamer59 , I can't try myself for now, but looking at your log, it seems it has some problem linking to REFPROP.

I do not think it has anything to do with the use of OMC, but rather a drawback of the current way to import Coolprop. The script you are running download the last development version of CoolProp, whereas it would make more sense to point to the last release, and make some debugging of the Linux script.

So I see 3 issues to solve:

@jowr
Copy link
Collaborator

jowr commented May 5, 2021

The basics work with OMC - many rough edges though. We have to continue working on it, but the information in this issue is outdated now.

@jowr jowr closed this as completed May 5, 2021
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

5 participants