title: Setting up GLEW and GLFW in VS Code with Visual C++
body: <p>I have a basic Visual C++ environment in Visual Studio Code. I've recently started to read about OpenGL and have been trying to set up GLEW and GLFW in VS Code. Almost all of the tutorials I find fall into one of the 2 categories:</p>
  <ol>
  <li>GLEW and GLFW setup with MSVC, but in Visual Studio.</li>
  <li>GLEW and GLFW setup in VS Code, but with minGW.</li>
  </ol>
  <p>I've read the documentation for MSVC command line and its options a few times and can't figure it out. I'm not familiar with Cmake and such, so I've been trying to do it via VS Code <em>tasks.json</em> file.</p>
  <p><a href="https://i.stack.imgur.com/kyZHg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kyZHg.png" alt="Directory structure" /></a></p>
  <p>My <em>tasks.json</em> file is as follows:</p>
  <pre><code>{
      &quot;version&quot;: &quot;2.0.0&quot;,
      &quot;tasks&quot;: [
  
          // BUILD TASK
          {
              &quot;type&quot;: &quot;shell&quot;,
              &quot;label&quot;: &quot;C/C++: build project&quot;,
              &quot;command&quot;: &quot;cl.exe&quot;,
              &quot;args&quot;: [
                  // exception handling args
                  &quot;/EHsc&quot;,
                  // including additional headers
                  &quot;/I${workspaceFolder}\\include\\glew\\include&quot;,
                  &quot;/I${workspaceFolder}\\include\\glfw\\include&quot;,
                  // obj files path
                  &quot;/Fo${workspaceFolder}\\bin\\&quot;,
                  // exe file path
                  &quot;/Fe:&quot;, &quot;${workspaceFolder}\\bin\\program.exe&quot;, 
                  // source files
                  &quot;${workspaceFolder}\\src\\*.cpp&quot;,
                  // library files
                  &quot;opengl32.lib&quot;,
                  &quot;${workspaceFolder}\\include\\glew\\lib\\Release\\x64\\glew32s.lib&quot;,
                  &quot;${workspaceFolder}\\include\\glfw\\lib-vc2019\\glfw3.lib&quot;
              ],
              &quot;options&quot;: {
                  &quot;cwd&quot;: &quot;${workspaceFolder}&quot;
              },
              &quot;problemMatcher&quot;: [
                  &quot;$msCompile&quot;
              ],
              &quot;group&quot;: {
                  &quot;kind&quot;: &quot;build&quot;,
                  &quot;isDefault&quot;: true
              }
          },
  
          // CLEAN TASK
          {
              &quot;type&quot;: &quot;shell&quot;,
              &quot;label&quot;: &quot;C/C++: clean project&quot;,
              &quot;command&quot;: &quot;del&quot;,
              &quot;args&quot;: [
                  &quot;${workspaceFolder}\\bin\\*&quot;,
              ],
              &quot;options&quot;: {
                  &quot;cwd&quot;: &quot;${workspaceFolder}&quot;
              }
          }
  
      ]
  }
  </code></pre>
  <p>And my <em>main.cpp</em> file has a few lines of code to open a window.</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;GL/glew.h&gt;
  #include &lt;GLFW/glfw3.h&gt;
  
  using namespace std;
  
  int main()
  {
      if (!glfwInit())
      {
          cout &lt;&lt; &quot;Failed to initialize GLFW&quot; &lt;&lt; endl;
          return -1;
      }
  
      glfwWindowHint(GLFW_SAMPLES, 4);
      glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
      glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
      glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  
      GLFWwindow* window;
      window = glfwCreateWindow(1000, 700, &quot;Test window 01&quot;, NULL, NULL);
      if (window == NULL)
      {
          cout &lt;&lt; &quot;Failed to open GLFW window&quot; &lt;&lt; endl;
          return -1;
      }
      glfwMakeContextCurrent(window);
  
      glewExperimental = true;
      if(glewInit() != GLEW_OK)
      {
          cout &lt;&lt; &quot;Failed to initialize GLEW&quot; &lt;&lt; endl;
          return -1;
      }
  }
  </code></pre>
  <p>Full terminal output while running build task at this <a href="https://pastebin.com/aGaEQtCg" rel="noreferrer">pastebin</a></p>