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

Cannot compile Tests with CoolProp - undeclared identifier '_fluidConstants' #10

Closed
slamer59 opened this issue Jan 15, 2018 · 5 comments

Comments

@slamer59
Copy link

Hello,
I'm still failing to compile test with CoolProp using the version 6.1.0 of CoolProp (described here)

Running TestStatesSupercritical

make -j4 -f ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical.makefile
clang   -fPIC -O0 -march=native      "-I/media/thomas/DATA/Developpments/ExternalMedia-fork/Modelica/ExternalMedia 3.2.1/Resources/Include" -I"/usr/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.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical.c
clang   -fPIC -O0 -march=native      "-I/media/thomas/DATA/Developpments/ExternalMedia-fork/Modelica/ExternalMedia 3.2.1/Resources/Include" -I"/usr/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_functions.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c
clang   -fPIC -O0 -march=native      "-I/media/thomas/DATA/Developpments/ExternalMedia-fork/Modelica/ExternalMedia 3.2.1/Resources/Include" -I"/usr/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_records.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_records.c
clang   -fPIC -O0 -march=native      "-I/media/thomas/DATA/Developpments/ExternalMedia-fork/Modelica/ExternalMedia 3.2.1/Resources/Include" -I"/usr/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_01exo.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_01exo.c
clang   -fPIC -O0 -march=native      "-I/media/thomas/DATA/Developpments/ExternalMedia-fork/Modelica/ExternalMedia 3.2.1/Resources/Include" -I"/usr/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_02nls.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_02nls.c
clang   -fPIC -O0 -march=native      "-I/media/thomas/DATA/Developpments/ExternalMedia-fork/Modelica/ExternalMedia 3.2.1/Resources/Include" -I"/usr/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_03lsy.o ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_03lsy.c
ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.c:85:53: warning: incompatible pointer types passing 'ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_Medium_ThermodynamicState *' (aka 'struct ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_Medium_ThermodynamicState_s *') to parameter of type 'ExternalThermodynamicState *' [-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)));
                                                    ^~~~~~~~~~~
/media/thomas/DATA/Developpments/ExternalMedia-fork/Modelica/ExternalMedia 3.2.1/Resources/Include/externalmedialib.h:144:96: note: passing argument to parameter 'state' here
        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:133:65: warning: incompatible pointer types passing 'ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_Medium_ThermodynamicState *' (aka 'struct ExternalMedia_Test_CoolProp_CO2_TestStatesSupercritical_Medium_ThermodynamicState_s *') to parameter of type 'ExternalThermodynamicState *' [-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)));
                                                                ^~~~~~~~~~~
/media/thomas/DATA/Developpments/ExternalMedia-fork/Modelica/ExternalMedia 3.2.1/Resources/Include/externalmedialib.h:143:107: note: passing argument to parameter 'state' here
        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:238:138: error: use of undeclared identifier '_fluidConstants'
  _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:383:138: error: use of undeclared identifier '_fluidConstants'
  _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;
                                                                                                                                         ^
2 warnings and 2 errors generated.
<builtin>: recipe for target 'ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.o' failed
make: *** [ExternalMedia.Test.CoolProp.CO2.TestStatesSupercritical_functions.o] Error 1
make: *** Waiting for unfinished jobs....
Compilation process failed. Exited with code 2.
@slamer59 slamer59 changed the title Cannot compile Tests with CoolProp Cannot compile Tests with CoolProp - undeclared identifier '_fluidConstants' Jan 15, 2018
@JonWel
Copy link
Contributor

JonWel commented Jan 16, 2018

I don't see why it has problem with _fluidConstants.
The class CoolPropSolver should inherit it from the class BaseSolver as it is a protected variable there.

@sjoelund
Copy link

Oh, the current OM frontend fails to evaluate some constants involving redeclare or something like that and just pretends it has no value, failing during code compilation. The problem with the type of the pointer to the record probably needs to be resolved by the ExternalMedia function taking a void* and casting it afterwards (because it's not specified how to generate a unique name for the structs in Modelica); you probably want to verify that the structs both have the same fields in the same order though (or simply avoid passing records in Modelica external "C" interface since it never works the way you want it to).

@SpaceSapien
Copy link

I was with several hacks able to compile the libExternalMedialLib.a library file to compile. I however am getting the same errors as stated here. @slamer59 were you able to figure out how to fix these issues?

@jowr jowr mentioned this issue Jan 6, 2021
@jowr
Copy link
Collaborator

jowr commented May 5, 2021

Hould the void casting suggested by @sjoelund be implemented? Is this still one way to improve things?

@casella
Copy link
Collaborator

casella commented Apr 12, 2023

All these issues should be fixed when using OMC 1.21.0 and ExternalMedia 3.3.2.

@casella casella closed this as completed Apr 12, 2023
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

6 participants