Using FreeGLUT in VSCode

Steps

  1. Download the minimal freeGLUT library,

  2. Extract the zip file,

  3. Copy ‘include’ folder from freeglut to ‘include’ folder of your compiler,

  4. Choose ‘Yes’ when explorer asks if you want to merge it into the already existing folder.

  5. Copy ‘libfreeglut.a’ and ‘libfreeglut_static.a’ from ‘lib’ folder of freeglut to ‘lib’ folder of your compiler,

  6. Download a sample OpenGL code for testing purpose,

  7. Copy ‘freeglut.dll’ from ‘bin’ folder of freeglut to where the sample code is present,

  8. Open the sample code in your VSCode,

  9. Start terminal in VSCode and cd to the location where your sample code is present,

  10. Run the following commands and enjoy!

    g++ -o “moon.o” -c “moon.cpp”
    g++ -L..\lib -o “moon.exe” “moon.o” -lfreeglut -lopengl32 -lglu32 -lwinmm -lgdi32
    ./moon
    

    VSCode - FreeGLUT

BTW, if you are using 64-bit GCC

  1. Copy ‘include’ folder from freeglut to ‘x86_64-w64-mingw32\include’ folder of your compiler,

  2. Accept the folder merge conflict,

  3. Copy ‘libfreeglut.a’ and ‘libfreeglut_static.a’ from ‘lib\x64’ folder of freeglut to ‘x86_64-w64-mingw32\lib’ folder,

  4. Instead of Step No. 8,

    • Copy ‘freeglut.dll’ from ‘bin\x64’ folder of freeglut to the folder with sample code.
  5. Instead of Step No. 11,

    • Run the following commands,
    g++ -c “moon.cpp” -o “moon.o”
    g++ -L..\x86_64-w64-mingw32\lib -o “moon.exe” “moon.o” -lfreeglut -lopengl32 -lglu32 -lwinmm -lgdi32
    ./moon
    
Previous:
Add VSCodium in Windows Context Menu