title: How to link against GLFW on Windows
body: <p>I am looking to learn how to use OpenGL with C++, and I am following the tutorial at <a href="https://open.gl/" rel="nofollow noreferrer">open.gl</a>. I am at <a href="https://open.gl/context" rel="nofollow noreferrer">this</a> part in the tutorial, and I am using GLFW. I tried following the instructions to build GLFW,</p>
  <blockquote>
  <p>After you've downloaded the GLFW binaries package from the website or
  compiled the library yourself, you'll find the headers in the include
  folder and the libraries for your compiler in one of the lib folders.</p>
  <p>-Add the appropriate lib folder to your library path and link with GLFW.</p>
  <p>-Add the include folder to your include path.</p>
  </blockquote>
  <p>I downloaded it, and moved the include folder into my MinGW include folder, but I was unsure where to find the lib folder, how to add it to my library path, or how to link it with OpenGL. This was not explained in the tutorial, and I could not find any instruction online about what this meant or how to do it. I proceeded without doing the other two steps, and when attempting to run the test code from the tutorial:</p>
  <pre><code>#include &lt;GLFW/glfw3.h&gt;
  #include &lt;thread&gt;
  
  int main()
  {
      glfwInit();
      std::this_thread::sleep_for(std::chrono::seconds(1));
      glfwTerminate();
  }
  </code></pre>
  <p>I received this error:</p>
  <pre><code>In file included from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\thread:35:0,
                   from D:\Files\Documents\Programming\opengl_tut.cpp:2:
  c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
  </code></pre>
  <p>I added -std=c++11 to my compiler flags, and I received this error:</p>
  <pre><code>D:\Files\Documents\Programming\opengl_tut.cpp: In function 'int main()':
  D:\Files\Documents\Programming\opengl_tut.cpp:7:10: error: 'std::this_thread' has not been declared
       std::this_thread::sleep_for(std::chrono::seconds(1));
  </code></pre>
  <p>Thinking the problem might just be with std::this_thread, I removed that line from my program, and ran it to see if initializing and terminating GLFW would return any errors. I got this:</p>
  <pre><code>C:\Users\Brett\AppData\Local\Temp\ccCJrDGj.o:opengl_tut.cpp:(.text+0xc): undefined reference to `glfwInit'
  C:\Users\Brett\AppData\Local\Temp\ccCJrDGj.o:opengl_tut.cpp:(.text+0x11): undefined reference to `glfwTerminate'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\Users\Brett\AppData\Local\Temp\ccCJrDGj.o: bad reloc address 0x20 in section `.eh_frame'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
  collect2.exe: error: ld returned 1 exit status
  </code></pre>
  <p>I think this may be because of the fact that I skipped earlier parts of the tutorials.</p>
  <p><strong>TL;DR</strong></p>
  <ul>
  <li>Tried to follow tutorial to use OpenGL</li>
  <li>Couldn't figure out how to link GLFW</li>
  <li>Couldn't find lib folder</li>
  <li>Got errors relating to std::this_thread</li>
  <li>Got error relating to GLFW</li>
  </ul>
  <p><strong>EDIT</strong></p>
  <p>I found some info on the GLFW site saying to use Cmake. I downloaded it and tried using it to build from the downloaded files. It made a new folder, but I'm not sure what to do with it.</p>