title: DLL project on Windows: Unresolved External Symbol
body: <p>I'm creating a DLL project with Visual Studio 2012 with the intent of calling the functions from a Delphi project. I've already turned off C++ name mangling by wrapping my functions in extern "C" { /* ... */ } but to avoid the C name decoration, I'm using a DEF file.</p>
  
  <p>Here's a snippet of code describing how I have things laid out:</p>
  
  <pre><code>// MyFile.h
  
  #ifdef MYPROJECT_EXPORTS
  #define MYPROJECT_API __declspec(dllexport)
  #else
  #define MYPROJECT_API __declspec(dllimport)
  #endif
  
  extern "C" {
      extern MYPROJECT_API void __stdcall do_something();
  }
  </code></pre>
  
  <p>The .cpp file is equivalently structured. Everything matches fine. </p>
  
  <p>I added a .def file to my project folder containing the following content:</p>
  
  <pre><code>LIBRARY MyProject
  EXPORTS
      do_something=_do_something@0
  </code></pre>
  
  <p>When I build my project, everything works okay. However when I add the linker option</p>
  
  <pre><code>/DEFS:MyProject.def
  </code></pre>
  
  <p>I start getting errors regarding unresolved external symbols. Has anybody had this kind of issue before? I'm not new to either C++ or C but this is my first time building a DLL on Windows, as I'm primarily a Unix developer. My hypothesis is that I'm either misunderstanding or misusing the __declspec decorator, as it only breaks when I link in the def file: when I remove that flag from the linker options it builds cleanly, except with C-style decorated symbols.</p>
  
  <p>EDIT: Thanks for the comments everyone, but I've gotten myself figured out now. My issue came from the fact that I was using the def file during the linking phase during creation of my DLL. I need to use the def file when using the DLL, not creating it, and everything is peachy.</p>