Note that there are some explanatory texts on larger screens.

plurals
  1. POForce solib dependency to have relative path of non-standard named shared library under a directory using gcc
    primarykey
    data
    text
    <p>I have an issue regarding the linking of a shared library with a non-standard naming convention under several directories. I need the generated executable to search for the shared library within the executables current location, but cannot find a command line parameter to force this behavior.</p> <p>To demonstrate this behavior all that is required is a shared library that is under a directory.</p> <pre><code>gcc -shared mylib.c -o some/dir/mylib.so gcc main.c -o main -Lsome/dir -l:mylib.so </code></pre> <p>The executable <b>main</b> gives the following ldd output:</p> <pre><code>ldd main some/dir/mylib.so (0xf76e2000) </code></pre> <p>The output that I require is:</p> <pre><code>ldd main mylib.so =&gt; some/dir/mylib.so (0xf7700000) </code></pre> <p>This output can be created if the library is named conventionally as <b>libmylib.so</b> rather than <b>mylib.so</b> like so:</p> <pre><code>mv some/dir/mylib.so some/dir/libmylib.so gcc main.c -o main -Lsome/dir -lmylib </code></pre> <p>This also drops the path <b>some/dir</b> in the ldd listing as required.</p> <p>I have investigated the use of rpath, and command line options for both the ld and gcc but I am unable to find a satisfactory solution. The strict requirements of a non-standard name and directory structure cannot be changed easily in this case.</p> <p>My question is how can I force the dependency of the library to be relative to the current directory rather than absolute as in the second ldd through gcc command line options.</p> <p>Thank you for your time, I hope I have explained the problem reasonably.</p> <p>Jon.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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