title: GCC: Specifying static/dynamic libraries to build against
body: <p>I have a simple C++ project that is structured as following:
  -A base project (ie: contains main() ), and links against everything else
  --A few custom libraries that are all built as static libs (ie: .a files)
  ---One of these static libraries uses features in a shared objective file (ie: a .so file)</p>
  
  <p>So, for example, this is how the project would appear (in a a tree view) at link time, after all the initial compiling has completed:</p>
  
  <pre><code>-myApp            (the main application)
  --libaudio.a      (the audio library I made)
  --libnetwork.a    (the networking library I made)
  --libvideo.a      (the video library I made)
  --libboost.a      (boost library)
  </code></pre>
  
  <p>Initially, this project build just fine. I just had to make sure I had a simple line in my makefile like this:</p>
  
  <pre><code>LIBS+=audio network video
  </code></pre>
  
  <p>Recently, I had to change how my audio library works. I now am required to use a third-party library, and all I have is the header file (.h) and the shared object (.so) files. So the new structure at link time looks like so:</p>
  
  <pre><code>-myApp              (the main application)
  --libaudio.a        (the audio library I made)
  ---libthirdparty.so (contains third-party audio handling functions)
  --libnetwork.a      (the networking library I made)
  --libvideo.a        (the video library I made)
  --libboost.a        (boost library)
  </code></pre>
  
  <p>This, in effect, means that I have an application with a static library linked in which makes calls to an external shared object. So, I put the header file in the appropriate location so I don't have any build errors when compiling libaudio.a, and put the libthirdparty.so file in a location where the linker searches for all my installed libraries.</p>
  
  <p>At this point, I cannot get the thing to build. It just doesn't see libthirdparty.so file, even though I know it is in a location that the linker searches by default. For some reason, wrapping my libaudio code, as in the example below (borrowed from www.cplusplus.com) fixes the build error:</p>
  
  <pre><code>my_C_CPP_Header.h:
  #ifndef MY_C_CPP_HEADER
  #define MY_C_CPP_HEADER
  
  /*check if the compiler is of C++*/
  #ifdef __cplusplus
  extern "C" {
  int myOtherCfunc(int arg1, int arg2); /* a C function */
  }
  #endif
  
  void myCppFunction1(); /* C++ function */
  void myCppFunction2(); /* C++ function */
  
  /*check if the compiler is of C++ */
  #ifdef __cplusplus
  }
  #endif
  
  #endif
  </code></pre>
  
  <p>Now, I have a new problem though. Now that it's building, it no longer statically links in libboost.a, and instead is crashing at startup due to libboost.so not being present. So, somehow this setup breaks how libboost is compiled in if I manage to get it to build at all.</p>
  
  <p>Any suggestions are welcome. Thank you all in advance.</p>