title: Can I mix static and shared-object libraries when linking?
body: <p>I have a C project that produces ten executables, all of which I would like to be linked in statically. The problem I am facing is that one of these executables uses a 3rd-party library of which only the shared-object version is available.</p>
  
  <p>If I pass the <code>-static</code> flag to gcc, ld will error saying it can't find the library in question (I presume it's looking for the .a version) and the executable will not be built.  Ideally, I would like to be able to tell 'ld' to statically link as much as it can and fail over to the shared object library if a static library cannot be found.</p>
  
  <p>In the interium I tried something like <code>gcc -static -lib1 -lib2 -shared -lib3rdparty foo.c -o foo.exe</code> in hopes that 'ld' would statically link in lib1 and lib2 but only have a run-time dependence on lib3rdparty. Unfortunatly, this did not work as I intended; instead the <code>-shared</code> flag overwrote the <code>-static</code> flag and everything was compiled as shared-objects.</p>
  
  <p>Is statically linking an all-or-nothing deal, or is there some way I can mix and match?</p>