Requesting help with using external C++ libraries

D
dwp@md1tech.co.uk
Thu, Apr 20, 2023 12:19 PM

Hello,

My objective is to develop an RCC worker that can utilise an external library which is not inherently integrated into openCPI. With standard C++, I would achieve this by simply adding the required include path and library to the makefile.

As an example, I attempted to construct a worker that could host a CivetWeb server. The first issue I ran into was getting the worker to build, giving the error:

In file included from source.cc:14:

web.h:4:10: fatal error: CivetServer.h: No such file or directory

    4 | #include “CivetServer.h”

      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

compilation terminated.

To determine if this was the sole problem, as a temporary solution I created a folder named 'civetweb' within 'source.rcc' containing the civetweb source code. Allowing it to be accessed directly. The component then compiled successfully.

I created an application that solely comprised of this worker, but when trying to run the application I got the following error:

app failed: Could not open RCC worker file /…/local.examples.source.rcc.0.ubuntu22_04.so: error loading "/…/local.examples.source.rcc.0.ubuntu22_04.so": /…/local.examples.source.rcc.0.ubuntu22_04.so: undefined symbol: _ZN12CivetHandler9handleGetEP11CivetServerP13mg_connectionPi

make: *** [/…/opencpi/cdk/include/application.mk:70: run] Error 1

Has anyone successfully used an external C++ library in a worker in this way? Any guidance would be really appreciated.

Thanks in advance,

Dan

Hello, My objective is to develop an RCC worker that can utilise an external library which is not inherently integrated into openCPI. With standard C++, I would achieve this by simply adding the required include path and library to the makefile. As an example, I attempted to construct a worker that could host a CivetWeb server. The first issue I ran into was getting the worker to build, giving the error: In file included from **source.cc:14**: **web.h:4:10:** **fatal error:** CivetServer.h: No such file or directory     4 | #include **“CivetServer.h”**       |          **^\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~** compilation terminated. To determine if this was the sole problem, as a temporary solution I created a folder named 'civetweb' within 'source.rcc' containing the civetweb source code. Allowing it to be accessed directly. The component then compiled successfully. I created an application that solely comprised of this worker, but when trying to run the application I got the following error: app failed: Could not open RCC worker file /…/local.examples.source.rcc.0.ubuntu22_04.so: error loading "/…/local.examples.source.rcc.0.ubuntu22_04.so": /…/local.examples.source.rcc.0.ubuntu22_04.so: undefined symbol: _ZN12CivetHandler9handleGetEP11CivetServerP13mg_connectionPi make: \*\*\* \[/…/opencpi/cdk/include/application.mk:70: run\] Error 1 Has anyone successfully used an external C++ library in a worker in this way? Any guidance would be really appreciated. Thanks in advance, Dan
DW
Dominic Walters
Thu, Apr 20, 2023 12:43 PM

Hi,

It sounds like you want to use a shared object library inside your RCC
Worker.
Is this correct?

If so, a quick way to do that is:

  • Add the include directory for the library to the includedirs
    attribute of your rccworker.
    • It sounds like you've done this, or have worked out an alternative way.
  • Create a Makefile inside your <worker>.rcc directory.
  • The Makefile should end with: include $(OCPI_CDK_DIR)/include/worker.mk
  • Before that you need to use RccCustomLibs to say where your shared
    object library is:
    • RccCustomLibs=/path/to/shared/object/library/lib.so

If you need a different shared object for various platforms, you can write
RccCustomLibs_<platform> instead.
AFAIK, there is no way to do this style of library include solely in XML at
the moment.

There is another approach to integrating external libraries using the
prerequisites folders, but this is more involved and I think undocumented
(although I could be wrong).

If you'd instead like to compile the library into your RCC Worker directly,
you can add the specific source files to the sourcefiles attriibute in
your rccworker.

Kind Regards,
D. Walters

On Thu, Apr 20, 2023 at 1:19 PM dwp@md1tech.co.uk wrote:

Hello,

My objective is to develop an RCC worker that can utilise an external
library which is not inherently integrated into openCPI. With standard C++,
I would achieve this by simply adding the required include path and library
to the makefile.

As an example, I attempted to construct a worker that could host a
CivetWeb server. The first issue I ran into was getting the worker to
build, giving the error:

In file included from source.cc:14:

web.h:4:10: *fatal error: *CivetServer.h: No such file or directory

 4 | #include *“CivetServer.h”*

   |          *^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

compilation terminated.

To determine if this was the sole problem, as a temporary solution I
created a folder named 'civetweb' within 'source.rcc' containing the
civetweb source code. Allowing it to be accessed directly. The component
then compiled successfully.

I created an application that solely comprised of this worker, but when
trying to run the application I got the following error:

app failed: Could not open RCC worker file /…/
local.examples.source.rcc.0.ubuntu22_04.so: error loading "/…/
local.examples.source.rcc.0.ubuntu22_04.so": /…/
local.examples.source.rcc.0.ubuntu22_04.so: undefined symbol:
_ZN12CivetHandler9handleGetEP11CivetServerP13mg_connectionPi

make: *** [/…/opencpi/cdk/include/application.mk:70: run] Error 1

Has anyone successfully used an external C++ library in a worker in this
way? Any guidance would be really appreciated.

Thanks in advance,

Dan


discuss mailing list -- discuss@lists.opencpi.org
To unsubscribe send an email to discuss-leave@lists.opencpi.org

Hi, It sounds like you want to use a shared object library inside your RCC Worker. Is this correct? If so, a quick way to do that is: * Add the include directory for the library to the `includedirs` attribute of your `rccworker`. * It sounds like you've done this, or have worked out an alternative way. * Create a `Makefile` inside your `<worker>.rcc` directory. * The `Makefile` should end with: `include $(OCPI_CDK_DIR)/include/worker.mk ` * Before that you need to use `RccCustomLibs` to say where your shared object library is: * `RccCustomLibs=/path/to/shared/object/library/lib.so` If you need a different shared object for various platforms, you can write `RccCustomLibs_<platform>` instead. AFAIK, there is no way to do this style of library include solely in XML at the moment. There is another approach to integrating external libraries using the `prerequisites` folders, but this is more involved and I think undocumented (although I could be wrong). If you'd instead like to compile the library into your RCC Worker directly, you can add the specific source files to the `sourcefiles` attriibute in your `rccworker`. Kind Regards, D. Walters On Thu, Apr 20, 2023 at 1:19 PM <dwp@md1tech.co.uk> wrote: > Hello, > > My objective is to develop an RCC worker that can utilise an external > library which is not inherently integrated into openCPI. With standard C++, > I would achieve this by simply adding the required include path and library > to the makefile. > > As an example, I attempted to construct a worker that could host a > CivetWeb server. The first issue I ran into was getting the worker to > build, giving the error: > > In file included from *source.cc:14*: > > *web.h:4:10:* *fatal error: *CivetServer.h: No such file or directory > > 4 | #include *“CivetServer.h”* > > | *^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~* > > compilation terminated. > > To determine if this was the sole problem, as a temporary solution I > created a folder named 'civetweb' within 'source.rcc' containing the > civetweb source code. Allowing it to be accessed directly. The component > then compiled successfully. > > > I created an application that solely comprised of this worker, but when > trying to run the application I got the following error: > > app failed: Could not open RCC worker file /…/ > local.examples.source.rcc.0.ubuntu22_04.so: error loading "/…/ > local.examples.source.rcc.0.ubuntu22_04.so": /…/ > local.examples.source.rcc.0.ubuntu22_04.so: undefined symbol: > _ZN12CivetHandler9handleGetEP11CivetServerP13mg_connectionPi > > make: *** [/…/opencpi/cdk/include/application.mk:70: run] Error 1 > > > Has anyone successfully used an external C++ library in a worker in this > way? Any guidance would be really appreciated. > > Thanks in advance, > > Dan > _______________________________________________ > discuss mailing list -- discuss@lists.opencpi.org > To unsubscribe send an email to discuss-leave@lists.opencpi.org >
D
dwp@md1tech.co.uk
Thu, Apr 20, 2023 1:27 PM

Hi Dominic,

Thanks for your quick and helpful reply. I followed your steps and am able to successfully compile the worker.
I no longer get the undefined symbol error when attempting to run the application which is great, however I am now getting the following:

app failed: Could not open RCC worker file /…/Dan-Playground/artifacts/local.Dan-Playground.examples.source.rcc.0.ubuntu22_04.so: error loading "/…/Dan-Playground/artifacts/local.Dan-Playground.examples.source.rcc.0.ubuntu22_04.so": libcivetweb.so.1: cannot open shared object file: No such file or directory

I know the path I specify in the makefile is correct as the component won’t compile when it is wrong. Is there a similar process I need to follow at the application level to point it to the shared object?

Many thanks,
Dan

Hi Dominic, Thanks for your quick and helpful reply. I followed your steps and am able to successfully compile the worker.\ I no longer get the undefined symbol error when attempting to run the application which is great, however I am now getting the following: ``` app failed: Could not open RCC worker file /…/Dan-Playground/artifacts/local.Dan-Playground.examples.source.rcc.0.ubuntu22_04.so: error loading "/…/Dan-Playground/artifacts/local.Dan-Playground.examples.source.rcc.0.ubuntu22_04.so": libcivetweb.so.1: cannot open shared object file: No such file or directory ``` I know the path I specify in the makefile is correct as the component won’t compile when it is wrong. Is there a similar process I need to follow at the application level to point it to the shared object? Many thanks,\ Dan
AO
Aaron Olivarez
Thu, Apr 20, 2023 2:43 PM

Hi Dan,

At the application level,  before you run the application, set the
LD_LIBRARY_PATH environment variable to the location of the shared object.

Aaron

On Thu, Apr 20, 2023 at 8:27 AM dwp@md1tech.co.uk wrote:

Hi Dominic,

Thanks for your quick and helpful reply. I followed your steps and am able
to successfully compile the worker.
I no longer get the undefined symbol error when attempting to run the
application which is great, however I am now getting the following:

app failed: Could not open RCC worker file /…/Dan-Playground/artifacts/local.Dan-Playground.examples.source.rcc.0.ubuntu22_04.so: error loading "/…/Dan-Playground/artifacts/local.Dan-Playground.examples.source.rcc.0.ubuntu22_04.so": libcivetweb.so.1: cannot open shared object file: No such file or directory

I know the path I specify in the makefile is correct as the component
won’t compile when it is wrong. Is there a similar process I need to follow
at the application level to point it to the shared object?

Many thanks,
Dan


discuss mailing list -- discuss@lists.opencpi.org
To unsubscribe send an email to discuss-leave@lists.opencpi.org

Hi Dan, At the application level, before you run the application, set the LD_LIBRARY_PATH environment variable to the location of the shared object. Aaron On Thu, Apr 20, 2023 at 8:27 AM <dwp@md1tech.co.uk> wrote: > Hi Dominic, > > Thanks for your quick and helpful reply. I followed your steps and am able > to successfully compile the worker. > I no longer get the undefined symbol error when attempting to run the > application which is great, however I am now getting the following: > > app failed: Could not open RCC worker file /…/Dan-Playground/artifacts/local.Dan-Playground.examples.source.rcc.0.ubuntu22_04.so: error loading "/…/Dan-Playground/artifacts/local.Dan-Playground.examples.source.rcc.0.ubuntu22_04.so": libcivetweb.so.1: cannot open shared object file: No such file or directory > > I know the path I specify in the makefile is correct as the component > won’t compile when it is wrong. Is there a similar process I need to follow > at the application level to point it to the shared object? > > Many thanks, > Dan > _______________________________________________ > discuss mailing list -- discuss@lists.opencpi.org > To unsubscribe send an email to discuss-leave@lists.opencpi.org >
D
dwp@md1tech.co.uk
Fri, Apr 21, 2023 8:17 AM

Hi Aaron,

Thanks that worked.

Dan

Hi Aaron, Thanks that worked. Dan
D
dwp@md1tech.co.uk
Mon, Jun 19, 2023 2:43 PM

Hi Dom,

Is there a way to specify multiple shared objects that need to be linked to?

I couldn’t see anything mentioned in the RCC dev guide.

Many thanks,
Dan

Hi Dom, Is there a way to specify multiple shared objects that need to be linked to? I couldn’t see anything mentioned in the RCC dev guide. Many thanks,\ Dan
DW
Dominic Walters
Mon, Jun 19, 2023 6:19 PM

Hi,

You have two main options:

I'd do the former for a quick solution to get something working but look to
move to the latter in the long term.

Cheers,
D. Walters

On Mon, Jun 19, 2023 at 3:43 PM dwp@md1tech.co.uk wrote:

Hi Dom,

Is there a way to specify multiple shared objects that need to be linked
to?

I couldn’t see anything mentioned in the RCC dev guide.

Many thanks,
Dan


discuss mailing list -- discuss@lists.opencpi.org
To unsubscribe send an email to discuss-leave@lists.opencpi.org

Hi, You have two main options: * Use `RccCustomLibs+=/path/to/compiled/library` in a Makefile * Mentioned on Pg 69 of https://opencpi.gitlab.io/releases/latest/docs/OpenCPI_RCC_Development_Guide.pdf * If you need to pick a different library depending on the RCC Platform, you can do `RccCustomLibs_centos7+=/path/to/compiled/centos7/library` * This variable can be a list of multiple libraries. * Your Makefile would minimally look like this: ```make RccCustomLibs_centos7+=/path/to/compiled/centos7/library include $(OCPI_CDK_DIR)/include/worker.mk ``` * `(dynamic/static)prereqlibs` * Mentioned in Section 3.1.8/9 of https://opencpi.gitlab.io/releases/latest/docs/OpenCPI_RCC_Development_Guide.pdf * If you use this, you need to build your library in the `prerequisites` folder of your project or the OpenCPI repo itself. * See `liquid` in `ocpi.assets` for an example: https://gitlab.com/opencpi/opencpi/-/blob/develop/projects/assets/prerequisites/liquid/install-liquid.sh * Warning: This is more complicated and error-prone, but more robust when porting to new RCC Platforms. I'd do the former for a quick solution to get something working but look to move to the latter in the long term. Cheers, D. Walters On Mon, Jun 19, 2023 at 3:43 PM <dwp@md1tech.co.uk> wrote: > Hi Dom, > > Is there a way to specify multiple shared objects that need to be linked > to? > > I couldn’t see anything mentioned in the RCC dev guide. > > Many thanks, > Dan > _______________________________________________ > discuss mailing list -- discuss@lists.opencpi.org > To unsubscribe send an email to discuss-leave@lists.opencpi.org >
D
dwp@md1tech.co.uk
Mon, Jun 19, 2023 7:36 PM

Hi Dom,

Thanks, I will look at this.

Dan

Hi Dom, Thanks, I will look at this. Dan