DEV Community

andac
andac

Posted on

Setting up OpenGL dev environment in Window

Recently I have been interested in graphic programming. I read a few tutorials and have found opengl is where I should start.

So I start setting up the opengl dev environment, but its not easy since I am using window (and vscode)...

Preparation

Setting up

glfw lib

https://www.glfw.org/docs/latest/build_guide.html#build_link_mingw

  • Static (I am using this)
    • libglfw3.a
  • For DLL version
    • add #define GLFW_DLL in the first line of code
    • use the libglfw3dll.a one in lib

vscode task.json arg

Make sure the flag order is correct

"args": [
        "-fdiagnostics-color=always",
        "-g",
        "${file}",
        "-o",
        "${fileDirname}\\${fileBasenameNoExtension}.exe",
        "src/glad.c",
        "-I./include",
        "-L./lib",
        "-lglfw3",
        "-lgdi32",
      ]
Enter fullscreen mode Exit fullscreen mode

file structure

Image description


Now I think I can start learning opengl :)

Image description

Here some problems I encountered when figuring how to setup the environment

lglfw3 not found

  • make sure the file structure is correct

"undefined reference to `glfwTerminate'"

  • linker problem
  • so make sure the compiler flag and order are correct

std::cout not working after adding glfw related functions

  • probably linker problem also
  • check the compiler flag and file structure are all correct

Ref

https://learnopengl.com/

https://stackoverflow.com/questions/22623087/undefined-reference-errors-when-linking-glfw-on-mingw

Top comments (0)