title: Unresolved Externals using Cmake and Visual Studio 2013
body: <p>I've been having problems with cmake and Visual Studio 2013 with SFML. When I try and compile my program, I'm getting unresolved externals for everything that uses SFML. I've had problems with this on multiple machines, and also with some other libraries in some case.</p>
  
  <p>I'm using the following command to generate my Visual Studio Project (inside a VisualStudioProject folder):</p>
  
  <blockquote>
    <p>Z:/Coding/cmake/cmake-3.1.1-win32-x86/bin/cmake.exe -G "Visual Studio 12" ..</p>
  </blockquote>
  
  <p>And this is my CMakeLists.txt (it's actually generated from a python script I wrote, but I doubt that's important). I can confirm that all the libraries are being found correctly.</p>
  
  <pre><code>cmake_minimum_required (VERSION 2.6)
  
  set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
  set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib )
  set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib )
  
  project(Game)
  
  include_directories( Z:/Coding/Libraries/SFML/SFML-2.2/include Z:/Coding/Game/src/win32 Z:/Coding/Game/src )
  
  find_library( SFML-GRAPHICS NAMES sfml-graphics PATHS Z:/Coding/Libraries/SFML/SFML-2.2/lib NO_DEFAULT_PATH )
  find_library( SFML-WINDOW NAMES sfml-window PATHS Z:/Coding/Libraries/SFML/SFML-2.2/lib NO_DEFAULT_PATH )
  find_library( SFML-SYSTEM NAMES sfml-system PATHS Z:/Coding/Libraries/SFML/SFML-2.2/lib NO_DEFAULT_PATH )
  
  add_executable( win32 "Z:/Coding/Game/apps/win32.cpp" )
  target_link_libraries( win32 ${SFML-GRAPHICS} ${SFML-WINDOW} ${SFML-SYSTEM} )
  </code></pre>
  
  <p>This is my simple SFML test program:</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iostream&gt;
  #include &lt;SFML/Graphics.hpp&gt;
  
  using namespace std;
  
  int main(int argc, char *argv[])
  {
      sf::RenderWindow window;
      window.create(sf::VideoMode(1280, 1024), "Test");
  
      while (true)
      {
          sf::Event ev;
  
          while (window.pollEvent(ev))
          {
              if (ev.type = sf::Event::EventType::Closed)
              {
                  window.close();
                  exit(1);
              }
          }
      }
  
      std::string hello = "Hello";
      cout &lt;&lt; hello &lt;&lt; endl;
  }
  </code></pre>
  
  <p>And I'm getting unresolved externals for the following:</p>
  
  <blockquote>
    <p>Error 1   error LNK2019: unresolved external symbol
    "__declspec(dllimport) public: __thiscall sf::String::String(char
    const *,class std::locale const &amp;)"
    (__imp_??0String@sf@@QAE@PBDABVlocale@std@@@Z) referenced in function
    _main Z:\Coding\Game\VisualStudioProject\win32.obj    win32</p>
    
    <p>Error 2   error LNK2019: unresolved external symbol
    "__declspec(dllimport) public: __thiscall sf::String::~String(void)"
    (__imp_??1String@sf@@QAE@XZ) referenced in function
    _main Z:\Coding\Game\VisualStudioProject\win32.obj    win32</p>
    
    <p>Error 3   error LNK2019: unresolved external symbol
    "__declspec(dllimport) public: __thiscall
    sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)"
    (__imp_??0VideoMode@sf@@QAE@III@Z) referenced in function
    _main Z:\Coding\Game\VisualStudioProject\win32.obj    win32</p>
    
    <p>Error 4   error LNK2019: unresolved external symbol
    "__declspec(dllimport) public: void __thiscall
    sf::Window::create(class sf::VideoMode,class sf::String const
    &amp;,unsigned int,struct sf::ContextSettings const &amp;)"
    (__imp_?create@Window@sf@@QAEXVVideoMode@2@ABVString@2@IABUContextSettings@2@@Z)
    referenced in function
    _main Z:\Coding\Game\VisualStudioProject\win32.obj    win32</p>
    
    <p>Error 5   error LNK2019: unresolved external symbol
    "__declspec(dllimport) public: void __thiscall
    sf::Window::close(void)" (__imp_?close@Window@sf@@QAEXXZ) referenced
    in function _main Z:\Coding\Game\VisualStudioProject\win32.obj    win32</p>
    
    <p>Error 6   error LNK2019: unresolved external symbol
    "__declspec(dllimport) public: bool __thiscall
    sf::Window::pollEvent(class sf::Event &amp;)"
    (__imp_?pollEvent@Window@sf@@QAE_NAAVEvent@2@@Z) referenced in
    function _main    Z:\Coding\Game\VisualStudioProject\win32.obj    win32</p>
    
    <p>Error 7   error LNK2019: unresolved external symbol
    "__declspec(dllimport) public: __thiscall
    sf::RenderWindow::RenderWindow(void)"
    (__imp_??0RenderWindow@sf@@QAE@XZ) referenced in function
    _main Z:\Coding\Game\VisualStudioProject\win32.obj    win32</p>
    
    <p>Error 8   error LNK2019: unresolved external symbol
    "__declspec(dllimport) public: virtual __thiscall
    sf::RenderWindow::~RenderWindow(void)"
    (__imp_??1RenderWindow@sf@@UAE@XZ) referenced in function
    _main Z:\Coding\Game\VisualStudioProject\win32.obj    win32</p>
    
    <p>Error 9   error LNK1120: 8 unresolved
    externals Z:\Coding\Game\bin\Debug\win32.exe  win32</p>
  </blockquote>
  
  <p>I've used this same style of script before with SFML in the past on Windows with an earlier VS successfully (at least I recall I have) so I think it's a new thing with VS 2013, but I'm utterly stumped.</p>
  
  <p>Thanks in advance.</p>
  
  <p>Note: This is a simplistic example. This style of CMakeLists.txt is generated by script because the main code-base it's used on is very large (originally Linux based, hence why '/'s are used everywhere).</p>