Linking against additional libraries

I have a static library that I have written and would like to link into my RCC worker.

I have:

  • Added the include directories using the IncludeDirs property in my worker XML.
  • Added the library name using the StaticPreReqLibs property in my worker XML.
  • Overridden the OCPI_PREREQUISITES_DIR env var to point to my library, prior to building.

This gets me seemingly very close! However I still get the error that:

Linking final artifact file “target-rocky8/myworker.so” and adding metadata to it…
g++: error: /home/myusername/opencpi/cdk/rocky8/lib/libMyStaticLib.a: No such file or directory

Apparently it’s still looking in the wrong place for the library (i.e. only inside the CDK). I notice in the documentaton it states that only libraries which are built into OpenCPI can be linked. Does this mean what I am trying to do is not possible? Or am I missing a step? Can I just go ahead and add my own symlinks to the CDK?

Thank you!

The staticprereqlibs method is used when the library is provided in a prerequisites folder. There is a way to add your own libraries in that style, but AFAIK it isn’t documented and has some drawbacks.

The alternative approach is to use RccCustomLibs in the RCC Worker Makefile.

Just assign this variable to the list of library files that you want to link against. For example:

RccCustomLibs=my_lib_1.a ../../common/my_lib_2/my_lib_2.so

If you have different versions of this library for different platforms, I think you can something like this instead:

RccCustomLibs_xilinx19_2_aarch64=my_lib_1.a ../../common/my_lib_2/my_lib_2.so

Thanks again @waltersdom :slightly_smiling_face: I somehow missed that section of the RCC documentation which also mentions the Makefile. Much appreciated!