title: C++: linker cannot find -lcrypto, but the library is in the path
body: <p>I am compiling a C++ application using GNU <code>g++</code>. The project takes advantage of  OpenSSL libraries.</p>
  
  <h2>Background</h2>
  
  <p>On my machine (a 64 bit CentOS quad core) I compile and link my files.</p>
  
  <pre><code>g++ -g -c -L/usr/local/lib/ -L/usr/lib64/ 
      -I/usr/local/include/ -I/usr/local/ssl/include/ 
      -lcrypto mysrc1.cpp mysrc2.cpp mysrc3.cpp
  
  g++ -L/usr/local/lib/ -L/usr/lib64/ -lcrypto 
      *.o -o ./myapp.out
  </code></pre>
  
  <p>My application uses function <code>MD5</code> which is contained in <code>libcrypto.so</code>. As you can see I specify to <code>g++</code> the dirs where to search using the <code>-L</code>, <code>-I</code> options and which libraries to look for with the <code>-l&lt;lib-name&gt;</code> option. There are some trivial paths like <code>/usr/local/lib</code> which can be omitted of course, but I specified them because the makefile is parametric. </p>
  
  <h2>The problem</h2>
  
  <p>My problem is that I can successfully compile my stuff (first command), <strong>but linking fails</strong> (second command):</p>
  
  <blockquote>
    <p>/usr/bin/ld: cannot find -lcrypto </p>
    
    <p>collect2: ld returned 1 exit status</p>
    
    <p>make: <em>*</em> [cppsims_par] Error 1</p>
  </blockquote>
  
  <p>But I did check folders and everything... <code>libcrypto.so</code> is inside <code>/usr/lib64/</code>. What is going on?</p>