title: What steps does gcc(or g++) take in searching for the location of libaries?
body: <p>When using the -l flag in a c++ makefile, I couldn't find information on what steps gcc takes in searching for that library. </p>
  
  <p>For clarity of what I'm asking, I'll make up an example answer (this is completely made up):</p>
  
  <ol>
  <li>First searches the -L flag directory</li>
  <li>Next searches the /lib directory</li>
  <li>Something something etc</li>
  </ol>
  
  <hr>
  
  <p>Some extra info: </p>
  
  <p>The reason I'm stuck in this is because I currently have a program that uses libconfig in the makefile like so:</p>
  
  <pre><code>g++ $(CFLAGS) -o libvldsk_config.so $(SRCDIR)/config.cpp -Wall -shared -fPIC -I$(SRCDIR) -I$(COMMON_SRCDIR) -lconfig
  </code></pre>
  
  <p>but this was made assuming that libconfig is installed via a package manager. I installed via source because the linux version was too old to have it in a package manager. And so I'm trying to modify my program that uses libconfig to search for the libconfig .so file in the system's /lib directory, and if it doesn't exist search for it in the current project directory.</p>