title: How do I export and link to a dll using Qt Creator on Windows?
body: <p>I have got a few Qt projects building on my Mac and I am currently trying to get the same code to build on Windows. In among these projects there is one dll (call it LibraryA) that exports a class (call it ClassA) that is linked to by a second dll (call it LibraryB).</p>
  
  <p>I have the following code that defines the dll export code to be used based on the compiler being used.</p>
  
  <pre><code>#ifdef _MSC_VER
  
      #if defined(LIBRARY_A)
          #define LIBRARY_A_EXPORT __declspec(dllexport)
      #else
          #define LIBRARY_A_EXPORT __declspec(dllimport)
      #endif
  
  #else
  
      #define LIBRARY_A_EXPORT
  
  #endif
  </code></pre>
  
  <p>I then incorporate this into my class definitions.</p>
  
  <pre><code>class LIBRARY_A_EXPORT ClassA
  </code></pre>
  
  <p>However, on Windows I get unresolved symbol __declspec(dllimport) in the LibraryB.</p>
  
  <p>What have I done wrong?</p>
  
  <p><strong>EDIT</strong> I created a couple of standalone projects to try and get this working (called LibraryA and LibraryB again). LibraryA successfully builds and in the LibraryB project I used the "Add Library" dialog, selecting External Library. This gives me the following .pro file entries which is still not working</p>
  
  <pre><code>win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../build-LibraryA-Desktop_Qt_5_5_1_MSVC2013_64bit-Debug/release/ -lLibraryA
  else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../build-LibraryA-Desktop_Qt_5_5_1_MSVC2013_64bit-Debug/debug/ -lLibraryA
  
  INCLUDEPATH += $$PWD/../build-LibraryA-Desktop_Qt_5_5_1_MSVC2013_64bit-Debug/debug
  DEPENDPATH += $$PWD/../build-LibraryA-Desktop_Qt_5_5_1_MSVC2013_64bit-Debug/debug
  </code></pre>