1

I need to dynamically link to a number of .so shared libraries from R. R can only do this one at a time using the dyn.load function, which takes the file path of the shared object. However, if the shared library that I load has dependencies on another shared library that I haven't already loaded, then the linking will fail.

Thus, I need to obtain a topological sort of the dependencies of a list of shared libraries so I can link them in the correct order. I realise that I can extract this information by running ldd on each shared library and parsing the results, but I wonder if there is an existing utility that can take a list of shared libraries and topologically sort them for me, to give me an easy load order.

I have looked into the lorder command, but I think this is only designed for static libraries (?), and also ar -ts, but I think this has the same problem. If I am wrong, feel free to correct me.

Is there any common Linux utility that will give me a linking order for these shared objects? I'm on CentOS 7 by the way.

2
  • Do you have the option to load with flag RTLD_LAZY mentioned in man dlopen? (I don't know if that is sufficient though).
    – meuh
    Jan 31 at 8:45
  • I believe R does use dlopen, but neither the RTLD_LAZY variable, nor the now = FALSE argument to the function seem to matter.
    – Migwell
    Jan 31 at 9:45

0

You must log in to answer this question.

Browse other questions tagged .