<p>I have a shared library that I wish to link an executable against using GCC. The shared library has a nonstandard name not of the form libNAME.so, so I can not use the usual -l option. (It happens to also be a Python extension, and so has no 'lib' prefix.)</p>

<p>I am able to pass the path to the library file directly to the link command line, but this causes the library path to be hardcoded into the executable.</p>

<p>For example:</p>

<pre><code>g++ -o build/bin/myapp build/bin/_mylib.so
</code></pre>

<p>Is there a way to link to this library without causing the path to be hardcoded into the executable?</p>

If you can copy the shared library to the working directory when g++ is invoked then this should work:
```
```
g++ -o build/bin/myapp _mylib.so other_source_files
```
```