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
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:
includedirs
rccworker
.
Makefile
inside your <worker>.rcc
directory.Makefile
should end with: include $(OCPI_CDK_DIR)/include/worker.mk
RccCustomLibs
to say where your shared
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 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 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 Aaron,
Thanks that worked.
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
Hi,
You have two main options:
Use RccCustomLibs+=/path/to/compiled/library
in a Makefile
RccCustomLibs_centos7+=/path/to/compiled/centos7/library
RccCustomLibs_centos7+=/path/to/compiled/centos7/library
include $(OCPI_CDK_DIR)/include/worker.mk
(dynamic/static)prereqlibs
prerequisites
liquid
in ocpi.assets
for an example:
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 Dom,
Thanks, I will look at this.
Dan