title: Unresolved external on static data member from another DLL
body: <p>Consider the following source of <code>From.dll</code> library defining the <code>From</code> class:</p>
  
  <p>Header:</p>
  
  <pre><code>// From.h
  #include &lt;afxwin.h&gt;
  #include &lt;afxext.h&gt;
  
  class AFX_EXT_CLASS From
  {
      public:
          static const char staticMember[666];
  };
  </code></pre>
  
  <p>Implementation:</p>
  
  <pre><code>// From.cpp
  #include "From.h"
  
  const char From::staticMember[] = "Total Crap";
  </code></pre>
  
  <p>This library static member <code>staticMember</code> must be used from the following <code>To</code> class, which must also give rise to a DLL (<code>To.dll</code>):</p>
  
  <p>Header:</p>
  
  <pre><code>// To.h
  #include &lt;afxwin.h&gt;
  #include &lt;afxext.h&gt;
  
  class AFX_EXT_CLASS To
  {
      public:
          static const char* retExtStatic();
  };
  </code></pre>
  
  <p>Implementation:</p>
  
  <pre><code>// To.cpp
  #include "To.h"
  #include "From.h"
  
  const char* To::retExtStatic()
  {
      return From::staticMember;
  }
  </code></pre>
  
  <p>But I keep getting this <code>LNK2001: unresolved external symbol "public: static char const * const From::staticMember" (?staticMember@From@@2QBDB)</code> when linking <code>To.dll</code>, no matter if it's directly on Visual Studio or if it's a cmake generated nmake:</p>
  
  <pre><code>Linking CXX shared library To.dll
     Creating library To.lib and object To.exp
  To.cpp.obj : error LNK2001: unresolved external symbol "public: static char const * const From::staticMember" (?staticMember@From@@2QBDB)
  To.dll : fatal error LNK1120: 1 unresolved externals
  </code></pre>
  
  <p>The first DLL is compiled and linked allright. The following are the relevant parts of my CMakeLists.txt:</p>
  
  <pre><code>add_definitions (-D_AFXDLL -D_AFXEXT -DPSAPI_VERSION=1)
  set (CMAKE_MFC_FLAG 2) # Use MFC in a shared DLL
  
  # FROM
  file (GLOB FROM ${CMAKE_CURRENT_SOURCE_DIR}/From.cpp)
  add_library (From SHARED ${FROM})
  target_link_libraries (From)
  
  # TO
  file (GLOB TO ${CMAKE_CURRENT_SOURCE_DIR}/To.cpp)
  add_library (To SHARED ${TO})
  target_link_libraries (To From)
  </code></pre>
  
  <p>What am I doing wrong to export this static data member?</p>