Problem running example c++ files

162 views
Skip to first unread message

Pavan Padubidri

unread,
Jul 9, 2018, 4:46:41 AM7/9/18
to coolprop-users
Hello,
I tried to run this example code from CoolProp website and got many errors like CPState.h not found , get_global_param_string(..) not declared in the scope.
I started debugging and figured out that  CoolProp.h and other header files has to included while compiling the example file. So I have kept the example file in CoolProp/include and use
 
g++ -I ..\externals\cppformat example.cpp

I am guessing I am not compiling the file properly. Please guide me on how to run the example file using gcc on 64bit Windows 10 or direct me to any article that tells how to use CoolProp in C++.

Ian Bell

unread,
Jul 14, 2018, 10:59:36 AM7/14/18
to coolpro...@googlegroups.com
Yup, you should use the cmake build system, that will make everything work totally seamlessly: http://www.coolprop.org/coolprop/wrappers/StaticLibrary/index.html#cmake-integration

Also, that code is for version 4, which is no longer supported.  You should try this instead: http://www.coolprop.org/coolprop/LowLevelAPI.html#introduction

--
You received this message because you are subscribed to the Google Groups "coolprop-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coolprop-users+unsubscribe@googlegroups.com.
To post to this group, send email to coolprop-users@googlegroups.com.
Visit this group at https://groups.google.com/group/coolprop-users.
For more options, visit https://groups.google.com/d/optout.

Pavan Padubidri

unread,
Aug 7, 2018, 1:54:58 AM8/7/18
to coolprop-users
Thank you for the reply. I followed the instructions for cmake, but could not run my example code. Can you please tell me where can I get a step by step instructions on running an example C code like this. It would be a great help if you could tell me where to place my example code and how to compile it linking other related files. Thank you


On Saturday, 14 July 2018 20:29:36 UTC+5:30, Ian Bell wrote:
Yup, you should use the cmake build system, that will make everything work totally seamlessly: http://www.coolprop.org/coolprop/wrappers/StaticLibrary/index.html#cmake-integration

Also, that code is for version 4, which is no longer supported.  You should try this instead: http://www.coolprop.org/coolprop/LowLevelAPI.html#introduction
On Mon, Jul 9, 2018 at 2:46 AM, Pavan Padubidri <idiot...@gmail.com> wrote:
Hello,
I tried to run this example code from CoolProp website and got many errors like CPState.h not found , get_global_param_string(..) not declared in the scope.
I started debugging and figured out that  CoolProp.h and other header files has to included while compiling the example file. So I have kept the example file in CoolProp/include and use
 
g++ -I ..\externals\cppformat example.cpp

I am guessing I am not compiling the file properly. Please guide me on how to run the example file using gcc on 64bit Windows 10 or direct me to any article that tells how to use CoolProp in C++.

--
You received this message because you are subscribed to the Google Groups "coolprop-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coolprop-user...@googlegroups.com.
To post to this group, send email to coolpro...@googlegroups.com.

Ian Bell

unread,
Aug 9, 2018, 12:25:10 AM8/9/18
to coolpro...@googlegroups.com
Here is a simple example that lays out how to make all the bits fit together to call the High-level interface: https://github.com/CoolProp/simple_cmake_example .  It's a similar story for the low-level interface example you highlight.

To unsubscribe from this group and stop receiving emails from it, send an email to coolprop-users+unsubscribe@googlegroups.com.
To post to this group, send email to coolprop-users@googlegroups.com.

Pavan Padubidri

unread,
Aug 9, 2018, 7:14:12 AM8/9/18
to coolprop-users
I have tried that already before. The problem is I get errors during making. Here is the error I get while building library.
[  0%] Built target generate_headers
[  2%] Building CXX object CMakeFiles/CoolProp.dir/src/CoolProp.cpp.obj
E:\CoolProp\src\CoolProp.cpp:37:18: fatal error: locale: No such file or directory
compilation terminated.
CMakeFiles\CoolProp.dir\build.make:132: recipe for target 'CMakeFiles/CoolProp.dir/src/CoolProp.cpp.obj' failed
mingw32-make.exe[2]: *** [CMakeFiles/CoolProp.dir/src/CoolProp.cpp.obj] Error 1
CMakeFiles\Makefile2:103: recipe for target 'CMakeFiles/CoolProp.dir/all' failed
mingw32-make.exe[1]: *** [CMakeFiles/CoolProp.dir/all] Error 2
Makefile:128: recipe for target 'all' failed
mingw32-make.exe: *** [all] Error 2

Ian Bell

unread,
Aug 16, 2018, 9:53:30 PM8/16/18
to coolpro...@googlegroups.com
What version of mingw do you use?  You'll need something that supports #include <locale>, which is a pretty standard standard header.  That is exactly your problem.  Google this?

To unsubscribe from this group and stop receiving emails from it, send an email to coolprop-users+unsubscribe@googlegroups.com.
To post to this group, send email to coolprop-users@googlegroups.com.

Pavan Padubidri

unread,
Sep 7, 2018, 9:11:21 AM9/7/18
to coolprop-users
Thanks, Fixed the compiler issue, got it compiling till 100%, but got this error at the end
CMakeFiles\main.dir/objects.a(mycode.cpp.obj):mycode.cpp:(.text+0x4e2): undefined reference to `CoolProp::PropsSI(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[2]: *** [CMakeFiles\main.dir\build.make:87: main.exe] Error 1
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:72: CMakeFiles/main.dir/all] Error 2
mingw32-make.exe: *** [Makefile:129: all] Error 2
I am sorry I am not familiar with making shared/static libraries. Please help me fix this

Pavan Padubidri

unread,
Sep 7, 2018, 9:13:22 AM9/7/18
to coolprop-users
Posting the compiler output here 
$ cmake --build .
Scanning dependencies of target generate_headers
git version 2.17.0.windows.1
cpversion.h is up to date
version written to hidden file: E:\ModeliCon_InfoTech\Project_sCO2\simple_cmake_example\externals\coolprop\.version for use in builders that don't use git repo
git is accessible at the command line
git revision is 514ee59e27e4414b44774bd48f8e81da73735dd7
gitrevision.h is up to date
all_fluids_JSON.h is up to date
all_incompressibles_JSON.h is up to date
mixture_departure_functions_JSON.h is up to date
mixture_binary_pairs_JSON.h is up to date
predefined_mixtures_JSON.h is up to date
all_cubics_JSON.h is up to date
cubic_fluids_schema_JSON.h is up to date
[  0%] Built target generate_headers
Scanning dependencies of target CoolProp
[  2%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/AbstractState.cpp.obj
[  4%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/CPfilepaths.cpp.obj
[  6%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/CPnumerics.cpp.obj
[  8%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/CPstrings.cpp.obj
[ 10%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Configuration.cpp.obj
[ 13%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/CoolProp.cpp.obj
[ 15%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/CoolPropTools.cpp.obj
[ 17%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/DataStructures.cpp.obj
[ 19%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Helmholtz.cpp.obj
[ 21%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/HumidAirProp.cpp.obj
[ 23%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Ice.cpp.obj
[ 26%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/MatrixMath.cpp.obj
[ 28%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/ODEIntegrators.cpp.obj
[ 30%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/PolyMath.cpp.obj
[ 32%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Solvers.cpp.obj
E:\ModeliCon_InfoTech\Project_sCO2\simple_cmake_example\externals\coolprop\src\Solvers.cpp:114:77: warning: optimization attribute on 'double CoolProp::Newton(CoolProp::FuncWrapper1DWithDeriv*, double, double, int)' follows definition but the attribute doesn't match [-Wattributes]
 double Newton(FuncWrapper1DWithDeriv* f, double x0, double ftol, int maxiter)
                                                                             ^
In file included from E:\ModeliCon_InfoTech\Project_sCO2\simple_cmake_example\externals\coolprop\src\Solvers.cpp:2:
E:/ModeliCon_InfoTech/Project_sCO2/simple_cmake_example/externals/coolprop/include/Solvers.h:90:15: note: previous definition of 'double CoolProp::Newton(CoolProp::FuncWrapper1DWithDeriv&, double, double, int)' was here
 inline double Newton(FuncWrapper1DWithDeriv &f, double x0, double ftol, int maxiter){
               ^~~~~~
E:\ModeliCon_InfoTech\Project_sCO2\simple_cmake_example\externals\coolprop\src\Solvers.cpp:160:98: warning: optimization attribute on 'double CoolProp::Halley(CoolProp::FuncWrapper1DWithTwoDerivs*, double, double, int, double)' follows definition but the attribute doesn't match [-Wattributes]
 double Halley(FuncWrapper1DWithTwoDerivs* f, double x0, double ftol, int maxiter, double xtol_rel)
                                                                                                  ^
In file included from E:\ModeliCon_InfoTech\Project_sCO2\simple_cmake_example\externals\coolprop\src\Solvers.cpp:2:
E:/ModeliCon_InfoTech/Project_sCO2/simple_cmake_example/externals/coolprop/include/Solvers.h:93:15: note: previous definition of 'double CoolProp::Halley(CoolProp::FuncWrapper1DWithTwoDerivs&, double, double, int, double)' was here
 inline double Halley(FuncWrapper1DWithTwoDerivs &f, double x0, double ftol, int maxiter, double xtol_rel = 1e-12){
               ^~~~~~
E:\ModeliCon_InfoTech\Project_sCO2\simple_cmake_example\externals\coolprop\src\Solvers.cpp:222:106: warning: optimization attribute on 'double CoolProp::Householder4(CoolProp::FuncWrapper1DWithThreeDerivs*, double, double, int, double)' follows definition but the attribute doesn't match [-Wattributes]
 double Householder4(FuncWrapper1DWithThreeDerivs* f, double x0, double ftol, int maxiter, double xtol_rel)
                                                                                                          ^
In file included from E:\ModeliCon_InfoTech\Project_sCO2\simple_cmake_example\externals\coolprop\src\Solvers.cpp:2:
E:/ModeliCon_InfoTech/Project_sCO2/simple_cmake_example/externals/coolprop/include/Solvers.h:96:15: note: previous definition of 'double CoolProp::Householder4(CoolProp::FuncWrapper1DWithThreeDerivs&, double, double, int, double)' was here
 inline double Householder4(FuncWrapper1DWithThreeDerivs &f, double x0, double ftol, int maxiter, double xtol_rel = 1e-12){
               ^~~~~~~~~~~~
E:\ModeliCon_InfoTech\Project_sCO2\simple_cmake_example\externals\coolprop\src\Solvers.cpp:285:78: warning: optimization attribute on 'double CoolProp::Secant(CoolProp::FuncWrapper1D*, double, double, double, int)' follows definition but the attribute doesn't match [-Wattributes]
 double Secant(FuncWrapper1D* f, double x0, double dx, double tol, int maxiter)
                                                                              ^
In file included from E:\ModeliCon_InfoTech\Project_sCO2\simple_cmake_example\externals\coolprop\src\Solvers.cpp:2:
E:/ModeliCon_InfoTech/Project_sCO2/simple_cmake_example/externals/coolprop/include/Solvers.h:84:15: note: previous definition of 'double CoolProp::Secant(CoolProp::FuncWrapper1D&, double, double, double, int)' was here
 inline double Secant(FuncWrapper1D &f, double x0, double dx, double ftol, int maxiter){
               ^~~~~~
E:\ModeliCon_InfoTech\Project_sCO2\simple_cmake_example\externals\coolprop\src\Solvers.cpp:359:111: warning: optimization attribute on 'double CoolProp::BoundedSecant(CoolProp::FuncWrapper1D*, double, double, double, double, double, int)' follows definition but the attribute doesn't match [-Wattributes]
 double BoundedSecant(FuncWrapper1D* f, double x0, double xmin, double xmax, double dx, double tol, int maxiter)
                                                                                                               ^
In file included from E:\ModeliCon_InfoTech\Project_sCO2\simple_cmake_example\externals\coolprop\src\Solvers.cpp:2:
E:/ModeliCon_InfoTech/Project_sCO2/simple_cmake_example/externals/coolprop/include/Solvers.h:87:15: note: previous definition of 'double CoolProp::BoundedSecant(CoolProp::FuncWrapper1D&, double, double, double, double, double, int)' was here
 inline double BoundedSecant(FuncWrapper1D &f, double x0, double xmin, double xmax, double dx, double ftol, int maxiter){
               ^~~~~~~~~~~~~
E:\ModeliCon_InfoTech\Project_sCO2\simple_cmake_example\externals\coolprop\src\Solvers.cpp:413:89: warning: optimization attribute on 'double CoolProp::Brent(CoolProp::FuncWrapper1D*, double, double, double, double, int)' follows definition but the attribute doesn't match [-Wattributes]
 double Brent(FuncWrapper1D* f, double a, double b, double macheps, double t, int maxiter)
                                                                                         ^
In file included from E:\ModeliCon_InfoTech\Project_sCO2\simple_cmake_example\externals\coolprop\src\Solvers.cpp:2:
E:/ModeliCon_InfoTech/Project_sCO2/simple_cmake_example/externals/coolprop/include/Solvers.h:81:15: note: previous definition of 'double CoolProp::Brent(CoolProp::FuncWrapper1D&, double, double, double, double, int)' was here
 inline double Brent(FuncWrapper1D &f, double a, double b, double macheps, double t, int maxiter){
               ^~~~~
[ 34%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/SpeedTest.cpp.obj
[ 36%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Cubics/CubicBackend.cpp.obj
[ 39%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Cubics/CubicsLibrary.cpp.obj
[ 41%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Cubics/GeneralizedCubic.cpp.obj
[ 43%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Cubics/UNIFAC.cpp.obj
[ 45%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Cubics/UNIFACLibrary.cpp.obj
[ 47%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Cubics/VTPRBackend.cpp.obj
[ 50%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/IF97/IF97Backend.cpp.obj
[ 52%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Helmholtz/FlashRoutines.cpp.obj
[ 54%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Helmholtz/Fluids/Ancillaries.cpp.obj
[ 56%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Helmholtz/Fluids/FluidLibrary.cpp.obj
[ 58%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Helmholtz/HelmholtzEOSBackend.cpp.obj
[ 60%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp.obj
[ 63%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Helmholtz/MixtureDerivatives.cpp.obj
[ 65%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Helmholtz/MixtureParameters.cpp.obj
[ 67%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Helmholtz/PhaseEnvelopeRoutines.cpp.obj
[ 69%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Helmholtz/ReducingFunctions.cpp.obj
[ 71%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Helmholtz/TransportRoutines.cpp.obj
[ 73%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Helmholtz/VLERoutines.cpp.obj
[ 76%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/REFPROP/REFPROPBackend.cpp.obj
[ 78%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/REFPROP/REFPROPMixtureBackend.cpp.obj
[ 80%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Incompressible/IncompressibleBackend.cpp.obj
[ 82%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Incompressible/IncompressibleFluid.cpp.obj
[ 84%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Incompressible/IncompressibleLibrary.cpp.obj
[ 86%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Tabular/BicubicBackend.cpp.obj
[ 89%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Tabular/TTSEBackend.cpp.obj
[ 91%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/Backends/Tabular/TabularBackends.cpp.obj
[ 93%] Building CXX object CoolProp/CMakeFiles/CoolProp.dir/src/CoolPropLib.cpp.obj
[ 95%] Linking CXX static library libCoolProp.a
[ 95%] Built target CoolProp
Scanning dependencies of target main
[ 97%] Building CXX object CMakeFiles/main.dir/mycode.cpp.obj
[100%] Linking CXX executable main.exe
Reply all
Reply to author
Forward
0 new messages