Note that there are some explanatory texts on larger screens.

plurals
  1. PORecursive shared library loading - Cannot open shared object file
    text
    copied!<p>I am compiling an application which consists of several projects, that generate dynamic libraries (Shared Libraries on LINUX). Of course that different projects are linking to the others that I've compiled. I am using CodeBlocks 10 under Ubuntu, using GCC compiler.</p> <p>Due to the fact that, according to the arguments specified by the user, different libraries shall be loaded, in my main application I am loading the appropriate library, according to the decision, with the following line:</p> <pre><code>dll = dlopen("my_library.so", RTLD_LAZY); </code></pre> <p>As specified in documentation, the dlopen loads libraries automatically If the library has dependencies on other shared libraries and the process is done recursively.</p> <p>The problem is that right after my dlopen, I call dlerror() in order to understand what's going on and I get the following error: </p> <blockquote> <p>../../../../gccDebug/os.so : Cannot open shared object file: No such file or directory.</p> </blockquote> <p>Just looking at the error, I completly understand it, because it is looking 2 folders below more than it should. The question is why?</p> <p>What I mean is: I use relative paths to explicitly load Shared Libraries on the projects. On my Main Application, the Working Directory is ../../gccDebug. I load, using dlopen, mylibrary.so, which explicitly loads (in project Options) ../../gccDebug/gui.so. This gui.so then also explicitly loads (in project options) ../../gccDebug/so.os</p> <p>What it seems to me that is happening, is that he is appending the paths making that on the 3rd "iteration" he is looking for a path which is already searching too many folders back than it should. If the first recursive loading (gui.so) works just fine, why does the 2nd recursive loading (so.os) is giving a strange path?? </p> <p>What is wrong with the recursive loading of the shared libraries using dlopen function?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload