title: How to specify the library version to use at link time?
body: <p>Following question <a href="https://stackoverflow.com/questions/3839756/how-do-applications-resolve-to-different-versions-of-shared-libraries-at-run-time">How do applications resolve to different versions of shared libraries at run time?</a>, I wondered how to specify on the link command line which version of the library to use?</p>
  
  <p>Let's say I have</p>
  
  <pre><code>libmy.so.1.0
  libmy.so.1    -&gt; libmy.so.1.0
  libmy.so.2.0
  libmy.so.2    -&gt; libmy.so.2.0
  libmy.so      -&gt; libmy.so.2
  </code></pre>
  
  <p>The usual way to specify the library to link with the executable does not show the version to use. Furthermore, it is very likely that one wants to link with the most recent version. Thus the usual line works fine in most cases.</p>
  
  <pre><code>gcc app.o -lmy -o app
  </code></pre>
  
  <p>What is the command line to link <code>app</code> that should use version 1 of the library?</p>