GMLC-TDC / HELICS-Examples

Examples for using HELICS with a variety of the supported programming languages
BSD 3-Clause "New" or "Revised" License
21 stars 19 forks source link

Failure to Compile CPP Examples #74

Closed BilalAhmad-Bhatti closed 1 year ago

BilalAhmad-Bhatti commented 2 years ago

I am trying to run the following cpp example from HELICS-Examples repo: https://github.com/GMLC-TDC/HELICS-Examples/blob/main/cpp/valueFederate1/valueFed.cpp using instructions: https://github.com/GMLC-TDC/HELICS-Examples

I have downloaded the HELICS pre-compiled library for cpp (v2.8). I have also set the HELICS_DIR environment variable to the required path: image

However, I keep getting the following error in cmake: image

nightlark commented 2 years ago

HELICS v2 is no longer supported -- though it does look like the C/C++/C++98 examples really need updating to support HELICS 3 as well. A version of the comboFed example that is used as part of the HELICS CI builds can be found in https://github.com/GMLC-TDC/HELICS/tree/main/examples

trevorhardy commented 2 years ago

I talked with @BilalAhmad-Bhatti about this and the current CMAKE files do not work for a HELICS v3 and need to be updated by somebody who knows CMAKE.

BilalAhmad-Bhatti commented 2 years ago

@nightlark I tried running combo federate example in the repo you mentioned. I get following: image

Is there a guide on running these?

nightlark commented 2 years ago

It isn’t set up to build as a standalone CMake project, only as a subproject of the top-level HELICS build.

On Tuesday, August 2, 2022, BilalAhmad-Bhatti @.***> wrote:

@nightlark https://github.com/nightlark I tried running combo federate example in the repo you mentioned. I get following: [image: image] https://user-images.githubusercontent.com/77303091/182474967-d46207e9-3dd6-4888-9329-2ac5d57920e2.png

— Reply to this email directly, view it on GitHub https://github.com/GMLC-TDC/HELICS-Examples/issues/74#issuecomment-1203222870, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA6JBZYLIGLXN4GRT6SPQVTVXGF7DANCNFSM55JCAOJQ . You are receiving this because you were mentioned.Message ID: @.***>

BilalAhmad-Bhatti commented 2 years ago

Is there a guide on running this?

nightlark commented 2 years ago

As it is mainly for one of the CI tests, there isn't any guide to using it. Building it is just a matter of setting one of the CMake options to ON when building HELICS, and then in the build folder it should be under the "bin" directory: https://docs.helics.org/en/latest/user-guide/installation/helics_cmake_options.html?highlight=HELICS_BUILD_EXAMPLES

BilalAhmad-Bhatti commented 2 years ago

I see. It seems like the standalone cmake version (which I suspect is in HELICS-examples repo) would be more useful for me since i am aiming for a standalone application. Any idea on how long it would take for that repo to be updated?

nightlark commented 2 years ago

I'm not sure. One thing I just noticed now though is that you mentioned downloading the precompiled HELICS library for cpp -- we don't have any downloads that include a precompiled c++ shared library, since compatibility is hard to guarantee with c++ shared libraries and things can break if the c++ compiler or standard library version used differ by even a minor/patch release compared to what the pre-compiled library is compiled with. The pre-compiled libraries included in releases are the c library, and the c++98 compatible headers that wrap the c library functions.

To get an install with a valid HELCS::helics-apps-cpp target you need to build HELICS from source with the HELICS_BUILD_CXX_SHARED_LIB and HELICS_BUILD_APP_LIBRARY options enabled. https://docs.helics.org/en/latest/user-guide/installation/helics_cmake_options.html?highlight=HELICS_BUILD_CXX_SHARED_LIB https://docs.helics.org/en/latest/user-guide/installation/helics_cmake_options.html?highlight=HELICS_BUILD_APP_LIBRARY

BilalAhmad-Bhatti commented 2 years ago

@nightlark Thanks for the clarification. If I understood correctly, for running examples in https://github.com/GMLC-TDC/HELICS/tree/main/examples , I need to build HELICS from source. Can you share the latest guide for building HELICS?

trevorhardy commented 2 years ago

Here you go, @BilalAhmad-Bhatti: https://docs.helics.org/en/latest/user-guide/installation/build_from_source.html

We've also got a video walking you through it on YouTube, recorded by a very handsome fellow with amazing technical skills you just happen to know: https://www.youtube.com/watch?v=BSwdT_OAtCU

BilalAhmad-Bhatti commented 2 years ago

Thanks Trevor