title: C++ dll in C program
body: <p>I'd like to create a dll library from <strong>C++</strong> code and use it in <strong>C</strong> program.
  I'd like to export only one function:</p>
  
  <pre><code>GLboolean load_obj (const char *filename, GLuint &amp;object_list);
  </code></pre>
  
  <p>Header file from library:</p>
  
  <pre><code>#ifndef __OBJ__H__
  #define __OBJ__H__
  
  #include &lt;windows.h&gt;  
  #include &lt;GL/gl.h&gt;
  #include &lt;GL/glext.h&gt;
  #include &lt;GL/glu.h&gt;
  #include &lt;GL/glut.h&gt;
  
  #if defined DLL_EXPORT
  #define DECLDIR __declspec(dllexport)
  #else
  #define DECLDIR __declspec(dllimport)
  #endif
  
  extern "C" GLboolean load_obj (const char *filename, GLuint &amp;object_list);
  
  #endif // __3DS__H__
  </code></pre>
  
  <p>in .cpp (in library project) function is also declared as:</p>
  
  <pre><code>extern "C" GLboolean load_obj (const char *filename, GLuint &amp;object_list)
  {
   code...
  }
  </code></pre>
  
  <p>File .lib is added in VS project options (Linker/Input/Additional dependencies). .dll is in folder where .exe is.
  When I compile C project - error: </p>
  
  <pre><code>Error   1   error C2059: syntax error : 'string'    
  </code></pre>
  
  <p>It is about part "extern "C" " in header file.</p>
  
  <p>I've tried to change header file to:</p>
  
  <pre><code>extern GLboolean load_obj (const char *filename, GLuint &amp;object_list);
  </code></pre>
  
  <p>then</p>
  
  <pre><code>Error   1   error C2143: syntax error : missing ')' before '&amp;'  
  Error   2   error C2143: syntax error : missing '{' before '&amp;'  
  Error   3   error C2059: syntax error : '&amp;' 
  Error   4   error C2059: syntax error : ')' 
  </code></pre>
  
  <p>and even when I changed <strong>&amp;</strong> to * appeared:</p>
  
  <pre><code>Error   6   error LNK2019: unresolved external symbol _load_obj referenced in function _main    main.obj    
  </code></pre>
  
  <p>I've no idea why it is wrong. .lib .h and .dll are properly added.</p>