title: How to reference C++ library with no class / namespace?
body: <p>I have a 3rd party C++ .lib that I would like to use in a C# application.</p>
  
  <p>My intent is to write a managed C++ wrapper .dll for the .lib, and then include that wrapper dll in my C# application, using a process roughly like <a href="http://tom-shelton.net/index.php/2008/12/11/creating-a-managed-wrapper-for-a-lib-file/" rel="nofollow">the one outlined at this link</a>. </p>
  
  <p>The header file for the .lib does not indicate any class declaration or namespace, just method names:</p>
  
  <pre><code>int CheckNamedVariable(const char* _name);
  int RegisterNamedVariable(const char* _name);
  double GetNamedVariableValue(int _id);
  double GetNamedVariableTypedValue(int _id, int _units);
  void SetNamedVariableValue(int _id, double _value);
  ... (etc)
  </code></pre>
  
  <p>I checked the lib with DUMPBIN /exports to see if I could glean any additional information, and got the following:</p>
  
  <pre><code>File Type: LIBRARY
  
       Exports
  
         ordinal    name
  
                    ?AircraftVarGet@@YANHHH@Z (double __cdecl AircraftVarGet(int,int,int))
                    ?CheckNamedVariable@@YAHPBD@Z (int __cdecl CheckNamedVariable(char const *))
                    ?DLLStart@@YGXXZ (void __stdcall DLLStart(void))
                    ?DLLStop@@YGXXZ (void __stdcall DLLStop(void))
                    ?GetAircraftVarEnum@@YAHPBD@Z (int __cdecl GetAircraftVarEnum(char const *))
                    ?GetModuleVar@@YANW4GAUGE_TOKEN@@@Z (double __cdecl GetModuleVar(enum GAUGE_TOKEN))
                    ?GetNameOfNamedVariable@@YAPBDH@Z (char const * __cdecl GetNameOfNamedVariable(int))
                    ?GetNamedVariableTypedValue@@YANHH@Z (double __cdecl GetNamedVariableTypedValue(int,int))
                    ?GetNamedVariableValue@@YANH@Z (double __cdecl GetNamedVariableValue(int))
                    ?GetUnitsEnum@@YAHPBD@Z (int __cdecl GetUnitsEnum(char const *))
                    ?IsPanelWindowVisibleIdent@@YAHI@Z (int __cdecl IsPanelWindowVisibleIdent(unsigned int))
                    ?Panels@@3PAUPANELS@@A (struct PANELS * Panels)
                    ?RegisterNamedVariable@@YAHPBD@Z (int __cdecl RegisterNamedVariable(char const *))
                    ?SendKeyEvent@@YAXII@Z (void __cdecl SendKeyEvent(unsigned int,unsigned int))
                    ?SetNamedVariableTypedValue@@YAXHNH@Z (void __cdecl SetNamedVariableTypedValue(int,double,int))
                    ?SetNamedVariableValue@@YAXHN@Z (void __cdecl SetNamedVariableValue(int,double))
                    _ImportTable
                    _Linkage
  
    Summary
  
            ED .debug$S
            14 .idata$2
            14 .idata$3
             4 .idata$4
             4 .idata$5
            1A .idata$6
  </code></pre>
  
  <p>In my managed wrapper project, I can point the Linker input to the .lib, but I'm not sure how to call the methods in the lib (the tutorial I linked to makes use of namespaces and classes). If it were a plain old DLL in a C#/VB project, I could view the object browser and get some idea of how to call the library. </p>
  
  <p>But given my C++ ignorance, I'm in the dark. Any help appreciated.</p>
  
  <p><strong>EDIT:</strong> 
  I tried just creating methods with the same name as the methods listed in the header, e.g.:</p>
  
  <pre><code>int VariableExporter::IsPanelWindowVisibleIdent(unsigned int panel_id)
  {
      return IsPanelWindowVisibleIdent(panel_id); 
  }
  </code></pre>
  
  <p>This is not doing what I'd hope, it's just recursively calling itself (until it has a - wait for it - Stack Overflow).</p>
  
  <p>Then I tried renaming the wrapper method like this:</p>
  
  <pre><code>int VariableExporter::IsPanelWindowVisibleIdent_New_Name(unsigned int panel_id)
  {
      return IsPanelWindowVisibleIdent(panel_id); 
  }
  </code></pre>
  
  <p>Now, although the C++ .DLL project and the C# project both compile, the C# project throws a FileNotFound exception when it tries to load that .DLL.</p>