Trouble setting up OpenGL on Windows (in VS Code)

I am following the tutorial text to setup OpenGL on Windows 11.
This is the main script(HelloWorld.cpp):

#include <GLFW/glfw3.h>

int main(void)
{
    GLFWwindow* window;

    /* Initialize the library */
    if (!glfwInit())
        return -1;

    /* Create a windowed mode window and its OpenGL context */
    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
    if (!window)
    {
        glfwTerminate();
        return -1;
    }

    /* Make the window's context current */
    glfwMakeContextCurrent(window);

    /* Loop until the user closes the window */
    while (!glfwWindowShouldClose(window))
    {
        /* Render here */
        glClear(GL_COLOR_BUFFER_BIT);

        /* Swap front and back buffers */
        glfwSwapBuffers(window);

        /* Poll for and process events */
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;

This is the c_cpp_properties.json file:

    {
        "configurations": [
          {
            "name": "GCC",
            "includePath": ["${workspaceFolder}/**",
            "C:\OpenGL\glfw.WIN64\include",
            "C:\OpenGL\glew\include"
            ],
            "defines": ["_DEBUG", "UNICODE", "_UNICODE"],
            "windowsSdkVersion": "10.0.22000.0",
            "compilerPath": "C:/msys64/mingw64/bin/g++.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-gcc-x64"
          }
        ],
        "version": 4
      }

This is the launch.json file:

    {
        "configurations": [
          {
            "name": "C/C++: g++.exe build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\msys64\ucrt64\bin\gdb.exe",
            "setupCommands": [
              {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
              },
              {
                "description": "Set Disassembly Flavor to Intel",
                "text": "-gdb-set disassembly-flavor intel",
                "ignoreFailures": true
              }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
          }
        ],
        "version": "2.0.0"
      }

This is the tasks.json file:

    {
        "tasks": [
          {
            "label": "C/C++: g++.exe build active file",
            "type": "cppbuild",
            "command": "C:\msys64\ucrt64\bin\g++.exe",
            "args": [
              "-fdiagnostics-color=always",
              "-g",
              "${file}",
              "-o",
              "${fileDirname}\${fileBasenameNoExtension}.exe",
          
              "-I",
              "C:\OpenGL\glfw.WIN64\include",
              "-I",
              "C:\OpenGL\glew\include",
              "-L",
              "C:\OpenGL\glew\lib\Release\x64",
              "-L",
              "C:\OpenGL\glfw.WIN64\lib-mingw-w64",
              "-lglfw3dll",
              "-lglew32",
              "-lopengl32"
            ],
            "options": {
              "cwd": "${fileDirname}"
            },
            "problemMatcher": ["$gcc"],
            "group": {
              "kind": "build",
              "isDefault": true
            },
            "detail": "Task generated by Debugger."
          }
        ],
        "version": "2.0.0"
      }

And this is the settings.json file that you get when opening Code Runner: Executor Map in the settings:

    {
        "code-runner.runInTerminal": false,

        "workbench.colorTheme": "Default Dark+",
        "editor.fontSize": 11,
        "editor.autoClosingBrackets": "always",
        "editor.autoClosingComments": "always",
        "editor.autoClosingQuotes": "always",
        "cmake.showOptionsMovedNotification": false,
        "C_Cpp.default.includePath": [
        "/usr/include"
        ],
        "code-runner.executorMap": {
            "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt -I C:\OpenGL\glfw.WIN64\include -I C:\OpenGL\glew\include -L C:\OpenGL\glew\lib\Release\x64 -L C:\OpenGL\glfw.WIN64\lib-mingw-w64 -lglfw3dll -lglew32 -lopengl32 && ./$fileNameWithoutExt",
            "javascript": "node",
            "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
            "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
            "zig": "zig run",
            "objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
            "php": "php",
            "python": "python -u",
            "perl": "perl",
            "perl6": "perl6",
            "ruby": "ruby",
            "go": "go run",
            "lua": "lua",
            "groovy": "groovy",
            "powershell": "powershell -ExecutionPolicy ByPass -File",
            "bat": "cmd /c",
            "shellscript": "bash",
            "fsharp": "fsi",
            "csharp": "scriptcs",
            "vbscript": "cscript //Nologo",
            "typescript": "ts-node",
            "coffeescript": "coffee",
            "scala": "scala",
            "swift": "swift",
            "julia": "julia",
            "crystal": "crystal",
            "ocaml": "ocaml",
            "r": "Rscript",
            "applescript": "osascript",
            "clojure": "lein exec",
            "haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
            "rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
            "racket": "racket",
            "scheme": "csi -script",
            "ahk": "autohotkey",
            "autoit": "autoit3",
            "dart": "dart",
            "pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
            "d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
            "haskell": "runghc",
            "nim": "nim compile --verbosity:0 --hints:off --run",
            "lisp": "sbcl --script",
            "kit": "kitc --run",
            "v": "v run",
            "sass": "sass --style expanded",
            "scss": "scss --style expanded",
            "less": "cd $dir && lessc $fileName $fileNameWithoutExt.css",
            "FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
            "fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
            "fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
            "fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
            "sml": "cd $dir && sml $fileName",
            "mojo": "mojo run",
            "erlang": "escript",
            "spwn": "spwn build",
            "pkl": "cd $dir && pkl eval -f yaml $fileName -o $fileNameWithoutExt.yaml",
            "gleam": "gleam run -m $fileNameWithoutExt"
        }
    }

Trying to run the program results in the following output:
[Running] cd “c:Users[MyUsername]DokumenteC++OpenGL-Setup” && g++ HelloWorld.cpp -o HelloWorld -I C:OpenGLglfw.WIN64include -I C:OpenGLglewinclude -L C:OpenGLglewlibReleasex64 -L C:OpenGLglfw.WIN64lib-mingw-w64 -lglfw3dll -lglew32 -lopengl32 && ./HelloWorld
Der Befehl “.” ist entweder falsch geschrieben oder
konnte nicht gefunden werden. [Basically the command “.” is either spelled incorrectly or could not be found.]

[Done] exited with code=1 in 1.264 seconds

I’m pretty sure it’s referring to ‘./$fileNameWithoutExt”,’ but because I don’t understand the line myself, I can’t really fix it…

I’ve tried just building the file to see if that works, this time it outputs the following:

  • Executing task: C/C++: g++.exe build active file

Starting build…
cmd /c chcp 65001>nul && C:msys64ucrt64bing++.exe -fdiagnostics-color=always -g C:Users[MyUsername]DokumenteC++OpenGL-SetupHelloWorld.cpp -o C:Users[MyUsername]DokumenteC++OpenGL-SetupHelloWorld.exe -I C:OpenGLglfw.WIN64include -I C:OpenGLglewinclude -L C:OpenGLglewlibReleasex64 -L C:OpenGLglfw.WIN64lib-mingw-w64 -lglfw3dll -lglew32 -lopengl32
Der Befehl “C:msys64ucrt64bing++.exe” ist entweder falsch geschrieben oder
konnte nicht gefunden werden. [The command “C:msys64ucrt64bing++.exe” is either spelled incorrectly or could not be found.]

Build finished with error(s).

  • The terminal process failed to launch (exit code: -1).
  • Terminal will be reused by tasks, press any key to close it.

I can compile programs that don’t use OpenGL and I can run them within VS Code too..

Does anyone know what I can do?

Thank you in advance!

New contributor

Yesko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật