title: How do I setup the SFML library in Linux Ubuntu?
body: <p>I am using the CLion IDE on linux which mandates developing using cmake. I have followed <a href="https://www.sfml-dev.org/tutorials/2.5/start-linux.php" rel="nofollow noreferrer">this</a> to get the following pieces of code.</p>
  
  <p>I have the following sample code : </p>
  
  <pre><code>#include &lt;SFML/Graphics.hpp&gt;
  
  int main()
  {
      sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
      sf::CircleShape shape(100.f);
      shape.setFillColor(sf::Color::Green);
  
      while (window.isOpen())
      {
          sf::Event event;
          while (window.pollEvent(event))
          {
              if (event.type == sf::Event::Closed)
                  window.close();
          }
  
          window.clear();
          window.draw(shape);
          window.display();
      }
  
      return 0;
  }
  </code></pre>
  
  <p>My CMakeLists.txt is as follows : </p>
  
  <pre><code>cmake_minimum_required(VERSION 3.12)
  project(SFML_codes)
  
  set(CMAKE_CXX_STANDARD 14)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  
  set(SFML_INCLUDE_DIR "/home/user/Desktop/SFML-2.5.0/include")
  set(SFML_LIBRARY_DIR "/home/user/Desktop/SFML-2.5.0/lib")
  link_directories("/home/user/Desktop/SFML-2.5.0/lib")
  include_directories("/home/user/Desktop/SFML-2.5.0/include")
  set(SFML_DIR "/home/user/Desktop/SFML-2.5.0/lib/cmake/SFML")
  find_package(SFML 2.5.0 COMPONENTS system window graphics network audio)
  
  if(SFML_FOUND)
  
      message(STATUS "SFML_INCLUDE_DIRS: ${SFML_INCLUDE_DIR}")
      message(STATUS "SFML_LIBRARIES: ${SFML_LIBRARIES}")
      message(STATUS "SFML_VERSION: ${SFML_VERSION}")
  
      include_directories(${SFML_INCLUDE_DIRS})
  
  endif()
  add_executable(SFML_codes main.cpp)
  
  target_link_libraries (SFML_codes sfml-graphics sfml-window sfml-system)
  </code></pre>
  
  <p>Output :</p>
  
  <pre><code>free(): invalid pointer
  
  Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
  </code></pre>
  
  <p>After a lot of struggle to eliminate linker errors, I am able to compile successfully. But on running the code I got an error which is trying to free/delete something which isn't a pointer. I debugged a little and it appears to be the first line in main method which cause this error. As per the link above it is supposed to run fine. </p>
  
  <p>To my surprise, the following code ran fine :</p>
  
  <pre><code>#include &lt;SFML/System.hpp&gt;
  #include &lt;iostream&gt;
  
  int main()
  {
      sf::Clock Clock;
      while (Clock.getElapsedTime().asSeconds() &lt; 5.f)
      {
          std::cout &lt;&lt; Clock.getElapsedTime().asSeconds() &lt;&lt; std::endl;
          sf::seconds(0.5f);
      }
  
      return 0;
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>