GMLC-TDC / HELICS

Hierarchical Engine for Large-scale Infrastructure Co-Simulation (HELICS)
https://docs.helics.org/en/latest/
BSD 3-Clause "New" or "Revised" License
127 stars 40 forks source link

c++ version conflict when incorporate HELICS to EnergyPlus #1440

Closed xcosmos6 closed 4 years ago

xcosmos6 commented 4 years ago

Hi,

I am trying to add HELICS as an external interface into EnergyPlus. However, HELICS requires c++14 in order to recognize the single quotes as number separators and EnergyPlus only work with c++11. I am wondering if there's a way to overcome this problem.

When building EnergyPlus, I included helics header files that would refer to the third party utilities/gmlc/utilities/timeRepresentation.hpp which defines constexpr fac10 and fac10f with single quotes as number separators. So the compiler gives error that those quote marks are not recognized.

I am working in a Ubuntu 18.04 virtual machine.

Thank you very much!

I also opened an issue with energyplus issue#8103

phlptp commented 4 years ago

HELICS only builds with C++14 or higher, there is quite a bit of C++14 code beyond the single quotes. It is used throughout the code so there is no desire or plan to make it C++11 compatible. HELICS 3.0 will require a C++17 compiler. The intention for interaction with older C++ variants including C++98, C++03, and C++11 is to use the C++98 interface, which is a wrapper around the C shared library which would be compatible with the older versions of C++. The C++98 Interface is header only, so once you have the C shared library does not require any additional libraries or building.

So that is the preferred way of linking with software requiring older variants of C++. Happy to help link with the C++98 interface if needed but that is the direction you should be heading.

xcosmos6 commented 4 years ago

Thank you very much! That helps. I included <helics/cpp98/ValueFederate.hpp> and <helics/cpp98/helics.hpp> in the file, then the compiler was able to get through that file. However, at the end of the compilation, the following errors showed up: [100%] Linking CXX executable ../../Products/energyplus ../../Products/libenergyplusapi.so.9.3.0: undefined reference to 'helicsErrorInitialize' ../../Products/libenergyplusapi.so.9.3.0: undefined reference to 'helicsCleanupLibrary' ../../Products/libenergyplusapi.so.9.3.0: undefined reference to 'helicsFederateFinalize' ../../Products/libenergyplusapi.so.9.3.0: undefined reference to 'helicsGetVersion' ../../Products/libenergyplusapi.so.9.3.0: undefined reference to 'helicsGetBuildFlags' ../../Products/libenergyplusapi.so.9.3.0: undefined reference to 'helicsGetCompilerVersion' Are there any other header I should have included? Or they should have been included in the helics/cpp98/helics.hpp file? Thank you very much again.

phlptp commented 4 years ago

I may have mislead you. The C++ is header only but it references the C shared library, so you will need to add a command -lhelicsSharedLib to link in the c based shared library.

xcosmos6 commented 4 years ago

Thank you. That worked.