title: What is the difference between shared and dynamic libraries in C?
body: <p>I don't understand the difference between the two types of libraries, and many websites say that they are the same thing, but at school we use two different commands to create them</p>
  
  <p><strong>dynamic library</strong></p>
  
  <pre><code>$ gcc -shared -o libsample.so lib.c
  $ gcc -o main main.c -ldl
  </code></pre>
  
  <p>to execute:</p>
  
  <pre><code>$ ./main ./libsample.so
  </code></pre>
  
  <p><strong>shared library</strong></p>
  
  <pre><code>$ gcc -shared -o libsample.so lib.c
  $ gcc -o main main.c -L. -lsample
  </code></pre>
  
  <p>to execute:</p>
  
  <pre><code>$ LD_LIBRARY_PATH=. ./main
  </code></pre>
  
  <p>Can someone help me in understanding the difference between the two "codes"?</p>