title: Create a DLL in C and link it from a C++ project
body: <p>As per title, I'm trying to build a DLL using C and link it from a C++ project. I read and followed different tutorials on internet but everytime there is something missing and I don't understand what. </p>
  
  <p>Here's what I did, step by step: </p>
  
  <p>I created a new Win32 project, named <code>testlib</code>, then, from the wizard, I chose "DLL" and "Empty project".</p>
  
  <p>Added a header: </p>
  
  <pre><code>//testlib.h
  
  #include &lt;stdio.h&gt;
  
  __declspec(dllexport) void hello();
  </code></pre>
  
  <p>Added a source; since I want it to be a C source I read I should simplly rename the .cpp file in .c, so</p>
  
  <pre><code>//testlib.c
  
  #include "testlib.h"
  
  void hello() {
      printf("DLL hello() called\n");
  }
  </code></pre>
  
  <p>Build succeded. </p>
  
  <p>Now I would like to use my useful dll in another project. </p>
  
  <p>Then: new project (<code>testlibUse</code>). This time I selected "Empty project". <br>
  No need to add an header, just created a cpp source</p>
  
  <pre><code>//main.cpp
  #include &lt;testlib.h&gt;
  
  int main() {
      hello();
  }
  </code></pre>
  
  <p>Then:</p>
  
  <ul>
  <li><p>I added the path to the folder where is <code>testlib.dll</code> in Properties->VC++ directories->Executable directories</p></li>
  <li><p>I added the path to the folder where is <code>testlib.h</code> in Properties->VC++ directories->Include directories</p></li>
  <li><p>I added the path to <code>testlib.lib</code> (included extension) in Properties->Linker->Input->Additional dependencies</p></li>
  </ul>
  
  <p>I tried to build but I got a linker error:</p>
  
  <blockquote>
    <p>LINK : C:\path\testlibUse\Debug\testlibUse.exe not found or not built by the last incremental link; performing full link<br>
    main.obj : error LNK2019: unresolved external symbol "void __cdecl hello(void)" (?hello@@YAXXZ) referenced in function _main<br>
    C:\path\testlibUse\Debug\testlibUse.exe : fatal error LNK1120: 1 unresolved externals </p>
  </blockquote>
  
  <p>If I go back to <code>testlib</code>, rename back <code>testlib.c</code> in <code>testlib.cpp</code> and rebuild the dll, then I am able to build <code>testlibUse</code> but I get a "dll not found" error at runtime.</p>
  
  <p>I tried also to change the configurations of both projects in "Release" (changing the path where needed), but nothing changed.</p>
  
  <p>Sorry for the long post but I think it was necessary to write down exactly what I did.</p>
  
  <p>Any suggestions?</p>
  
  <p>Besides, are there any configuration parameters I need to change if I want to use my dll in a Qt project? </p>