Universal Robots Forum

Cpp Daemon With External Libraries

I wrote my camera driver as a cpp daemon, and it uses some external libraries (the camera’s Sdk). The libraries were compiles using the urtools’ cross compiler, and after adding the lib directory to $LD_LIBRARY_PATH, the daemon seem to work fine (if run as a standalone from the shell). But still Polyscope does not seem to be able to run the daemon.
No error is shown (except “My Daemon Fails”) but i have narrowed it down to the fact of adding the libraries to the compilation.

Simply adding the library’s name to the HW_LIBS variable in SConscript (without referencing to that library anywhere) causes the daemon to fail.

Is there anything i should now about this? should i put my library files in a specific location? or specify their location somewhere for Polyscope to look?

EDIT : I have noticed that start-ursim.sh overrides $LD_LIBRARY_PATH to be in /opt/urtool-3.0/lib (a folder which does not exists, at least not on the starter package). But moving my library files (*.so) in there still did not work.

You can specify to your cpp app a ‘runt-time search path’ which is called RPATH.
So I suggest you add a relative RPATH with all your libraries. For example in your SConscript:

env.Program(target = 'camera_app',
        source = 'some sources',
        LIBS = MY_LIBS)

Now, your ‘camera_app’ will always search for libraries in the relative directory ‘./libs’. Then before using maven to package a .urcap just add the folder ‘libs’ to the directory of your ‘camera_app’.

Another way is to give RPATH an absolute path and copy the libraries to the robot controller yourself using ftp.

Here is the description in SCons manual:

RPATH: A list of paths to search for shared libraries when running programs. Currently only used in the GNU (gnulink), IRIX (sgilink) and Sun (sunlink) linkers. Ignored on platforms and toolchains that don’t support it. Note that the paths added to RPATH are not transformed by scons in any way: if you want an absolute path, you must make it absolute yourself.

1 Like