title: C++ how to tell if static .lib is valid, callable from external code
body: <p>I've got a C++ .lib file provided by a vendor, with some sparse documentation and sample code. My task is to use it to build a prototype to showcase the vendor's technology.</p>
  
  <p>Being a (mostly) C#/Java developer, I'm trying to hack together something basic using this lib and using the tricks I know - all of which are leading me to believe I'm missing something (or the lib is...)</p>
  
  <p>dumpbin /exports foo.bin doesn't show any exported functions:</p>
  
  <pre><code>E:\SDKs\Acme\lib&gt;dumpbin /exports foo.lib
  Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  Dump of file foo.lib
  
  File Type: LIBRARY
  
    Summary
  
     1AB29A0 .bss
        6BD0 .data
        AAE0 .nocopy
      C5A0E0 .noinit
      1954D0 .rdata
       19000 .scratch
       C1CA0 .text
      492000 .vram
  </code></pre>
  
  <p>lib /list foo.lib shows a number what I assume are function names with a .w32o extension. Based on the function names, and the type of business the vendor is in, these all look valid. </p>
  
  <p>The vendor's README says to initiate the library by calling its __foo_entry() function. Dumpbin /SYMBOLS does in fact show this function:</p>
  
  <pre><code>040 00002826 SECT1  notype ()    External     | __foo_entry
  </code></pre>
  
  <p>The vendor's sample code loads the library (using dlopen, which is a *nix way of loading a library according to <a href="http://en.wikipedia.org/wiki/Dynamic_loading" rel="nofollow">my understanding</a>.)</p>
  
  <p>But I've created a VS2010 project, and have tried to load the library like so:</p>
  
  <pre><code>System::Void load(){
  
      HINSTANCE sdl_library = LoadLibrary(TEXT("E:\\SDKs\\Acme\\lib\\foo.lib"));
  
      if (sdl_library == NULL) {
          Console::WriteLine("error");
      } else {
          Console::WriteLine("success");
      }
   }
  </code></pre>
  
  <p>When the project tries to the line containing "LoadLibrary", the debugger throws a Bad Image exception: "E:\SDKs\Acme\lib\foo.lib" is either not designed to run on Windows or it contains an error..."</p>
  
  <p>Dependency walker is not much help here because the .lib is static. </p>
  
  <p>So: is it a valid .lib or not? </p>
  
  <p>The visual studio command line tools seem to indicate it is valid, but trying to load it into a project indicates it's not.</p>