title: c++ exporting and using dll function
body: <p>I can't quite figure out where there is a mistake. I am creating a DLL and then using it in a C++ console program (Windows 7, VS2008). But I get <code>LNK2019 unresolved external symbol</code> when trying to use the DLL functions.</p>
  
  <p>First the export:</p>
  
  <pre><code>#ifndef __MyFuncWin32Header_h
  #define __MyFuncWin32Header_h
  
  #ifdef MyFuncLib_EXPORTS
  #  define MyFuncLib_EXPORT __declspec(dllexport)
  # else
  #  define MyFuncLib_EXPORT __declspec(dllimport)
  # endif  
  
  #endif
  </code></pre>
  
  <p>This is one header file I then use in:</p>
  
  <pre><code>#ifndef __cfd_MyFuncLibInterface_h__
  #define __cfd_MyFuncLibInterface_h__
  
  #include "MyFuncWin32Header.h"
  
  #include ... //some other imports here
  
  class  MyFuncLib_EXPORT MyFuncLibInterface {
  
  public:
  
  MyFuncLibInterface();
  ~MyFuncLibInterface();
  
  void myFunc(std::string param);
  
  };
  
  #endif
  </code></pre>
  
  <p>Then there is the dllimport in the console program, which has the DLL included in the Linker->General->Additional Library Directories:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;iostream&gt;
  
  
  __declspec( dllimport ) void myFunc(std::string param);
  
  
  int main(int argc, const char* argv[])
  {
      std::string inputPar = "bla";
      myFunc(inputPar); //this line produces the linker error
  }
  </code></pre>
  
  <p>I can't figure out what's going wrong here; it must be something really simple and fundamental. </p>