Many programmers prefer OpenGL for graphics. If you are one of them, you are strongly advised by its producer, to use a window toolkit (such as freeGLUT) and an OpenGL's extension library (such as GLEW). This guide will help you get over the first challenge of using OpenGL with freeGLUT and GLEW: Installing and setting them up, and creating your first project with OpenGL-freeGLUT-GLEW Template in Visual Studio 2022. It will assume your platform is Windows 10 or 11. It is addressing the beginner. He can learn three ways for create project with FreeGLUT and GLEW: 1st targeting platform x32, 2nd targeting platform x64, and 3rd project with source code compiled by CMake and Visual Studio. Visual Studio 2022 is by default x64. However it runs interchangeably x32 and x64 applications.

Part 1
Part 1 of 18:

Configuring Visual Studio

  1. 1
    Highlight what you expect to do. Highlight step or sub-step or part of it and then do it. For example see picture above.
  2. 2
    Download Visual Studio 2022. If you have not done so, you can download it from https://www.visualstudio.com/downloads.
  3. Advertisement
Part 2
Part 2 of 18:

Downloading freeGLUT and GLEW

  1. 1
    Create folders GL and GLP. Open Windows's File Explorer > Navigate to disk (directory) C.
    • If folders GL and GLP exist it's okay.
    • If they do not, right click in empty area > select New > Folder > type GL > hit Enter. By same way create folder GLP.
  2. 2
    Download the application GLEW.
    • If you already have downloaded GLEW binaries and have them in folder GL, it's okay.
    • If you do not have them, right-click on following link and select Open Link in New Window http://glew.sourceforge.net. Below Downloads, besides Binaries, click "Windows 32-bit and 64-bit".
    • In downloading window, if you see stripes in folder's icon, right click and select "Extract all".
    • Click folder glew-2.1.0 > right click > select Copy.
    • (If folder glew-2.1.0-win32 is downloaded, double click it to get glew-2.1.0).
    • Navigate to C: > GL > right click > select Paste.
    • (Alternatively, open "Files Explorer" window > C: > GL. Go to downloading window > click downloaded folder and drag into C:\GL)
    • Copy GLEWbin > click (if needed twice) on folder's name > Paste > hit Enter.
  3. 3
    Download freeglut 3.0.0 MSVC Package. In following link right click and select Open Link in New Window https://www.transmissionzero.co.uk/software/freeglut-devel/. In section (see above image) freeglut 3.0.0 MSVC Package click Download freeglut 3.0.0 for MSVC.
    • In downloading window if you see stripes on folder's icon (compressed folder), double click it.
    • Click folder freeglut (uncompressed) > right click > select Copy.
    • Navigate to C: > GL. Right click > select Paste.
    • (Alternatively, open "Files Explorer" window > C: > GL. Go to downloading window > click downloaded folder and drag into C:\GL)
    • Copy GLUTbin > click (if needed twice) on folder's name > Paste > hit Enter.
    • Now in folder GL you have folders: GLUTbin and GLEWbin.
  4. Advertisement
Part 3
Part 3 of 18:

Creating Project GLUTx32-GLEWx32-0

  1. 1
    Create an empty project.
    • If Visual Studio is not open. Open it > click Create a new project > find (see image above, if necessary scroll down the list. Icon is different than in image, it doesn't matter though) Empty Project Start from scratch with C++ for Windows. Provides no starting files., click it > click Next.
      • In Configure your new project wizard for "Project name" type (or copy and paste) GLUTx32-GLEWx32-0
      • Copy C:\GLP and paste in "Location" text field.
      • Check "Place solution and project in the same directory".
      • Click Create.
      • Wait till Visual Studio instance appears.
    • If Visual Studio is open. In main menu click File > New > Project… > the rest as above.
  2. 2
    Add your Source file to the project.
    • In "Solution Explorer" window right click the "Source Files" folder (the last one) > click "Add" > "New Item…"
    • Copy Main > in the "Add New Item" wizard delete "FileName" > paste > click Add. The source file Main.cpp will open in the main text editor but leave the file blank for now.
  3. Advertisement
Part 4
Part 4 of 18:

Installing GLUTx32 and GLEWx32 in the Project

  1. 1
    Configure "Properties Pages". In Solution Explorer, right click on the name of your project (name in image is different but it does'nt matter), that is GLUTx32-GLEWx32-0, and select Properties (the last one). .
  2. 2
    Add dll files paths (addresses) to "System Variables". In Windows search text field (bottom left of the screen) type envir > hit Enter. "System Properties" wizard is thrown.
    • Select the "Advanced" tab from the top bar > click Environment Variables.... "Environment Variables" wizard is thrown.
    • Double click the "Path" (or "PATH") Variable in the "System Variables" section. "Edit environement variable" wizard is thrown.
    • Copy C:\GL\GLUTbin\bin > click New > Paste.
    • Copy C:\GL\GLEWbin\bin\Release\Win32 > click New > Paste.
    • Click OK in all 3 wizards.
    • Close Visual Studio > in thrown wizard asking "Save changes to the following items?" click Save.
    • Restart your PC > open Visual Studio. If project opens it's okay. If not, in "Open recent" list, click "GLUTx32-GLEWx32-0.sln", the first one. Now your project is open ready for test.
  3. Advertisement
Part 5
Part 5 of 18:

Testing Project GLUTx32-GLEWx32-0 and Correcting errors

  1. 1
    Test your project. Right click on following link and select Open Link in New Window badprog. Scroll down the page and find section Testing the setup (see image below). Copy code and paste in Main.cpp code area > in main menu select x86 > hit Ctrl+F5.
  2. 2
    Correct errors if any. Files are missing. Copy GLUTx32-GLEWx32-0 and paste in File Explorer Address Bar. You should see file you added Main.cpp, and 4 other files added by Visual Studio. If they are missing you missed add file Main.cpp. Go to Part 3, step 2, and add it now.
    • In "Error List" if you see error about
      • file with extension .h go to previous Part, step 1, sub step 2. Additional Include Directories and follow instructions. Also check whether folders GLEWbin and GLUTbin exist in C:\GL.
      • file with extension .lib go to previous Part, step 1, sub step 3. Additional Library Directories, and follow instructions. Also to step 1, sub step 4. Additional Library Directories.
      • "entry point must be defined" go to step 1, sub step 5. System and follow instructions.
    • Thrown wizard about system or file .dll go to previous Part, step 2 and 3 and follow instructions.
    • For other errors, if you cannot correct them, close Visual Studio > delete project folder GLUTx32-GLEWx32-0 which lives in C:\GLP > open Visual Studio > repeat set up from Part 3. Good job.
  3. Advertisement
Part 6
Part 6 of 18:

Creating Project with GLUTx32-GLEWx32 Template

  1. 1
    Create template. Go to Visual Studio main menu and, while "GLUTx32-GLEWx32-0" is open, click Project > Export Template... (see above image).
    • On Export template Wizard check Project Template, if it's not checked. Click Next >.
    • On Select Template Options, if Template name is GLUTx32-GLEWx32-0 it's okay. If it's not, type (or copy and paste) GLUTx32-GLEWx32-0. Click Finish.
    • Template has been created. Close thrown window with template's path.
  2. 2
    Create project. In Visual Studio GUI, click File > New > Project....
    • In Create a new project wizard, in the list of templates, select GLUTx32-GLEWx32-0 > click Next.
    • In Configure your new project wizard, if "Project name" is GLUTx32-GLEWx32-01 it's okay. If is not copy GLUTx32-GLEWx32-01 and paste.
      • Location should be C:\GLP\. If it's not, copy C:\GLP\ and paste.
      • Be sure Place solution and project in the same directory is checked.
      • Click Create.
    • In Visual Studio's GUI main menu, select x86 > hit Ctrl+F5.
    • You should see two windows: one black (the console) and other with white square in black background. Good job.
    • TIP. Remember, when you create project with this template, in Visual Studio GUI main menu select x86.
  3. Advertisement
Part 7
Part 7 of 18:

Creating Project targeting x64 Platform

  1. 1
    Create folders GL and GLP. Open Windows's File Explorer > Navigate to disk (directory) C.
    • If folders GL and GLP exist it's okay.
    • If they do not, right click in empty area > select New > Folder > type GL > hit Enter. By same way create folder GLP.
  2. 2
    Download libraries freeGLUT and GLEW. If you have not already downloaded them go to Part 2, steps 2 and 3 and follow them.
  3. 3
    Create empty project.
    • If Visual Studio is not open. Open it > click Create a new project > find (see image above, if necessary scroll down the list. Icon is different than in image, it doesn't matter though) Empty Project Start from scratch with C++ for Windows. Provides no starting files., click it > click Next.
      • In Configure your new project wizard, for "Project name", type (or copy and paste) GLUTx64-GLEWx64-0
      • "Location" should be C:\GLP. If it's not, delete everything, copy C:\GLP\ and paste.
      • Check "Place solution and project in the same directory".
      • Click Create.
      • Wait till Visual Studio instance appears.
    • If it is open. Click File > New > Project… . The rest as above.
  4. 4
    Add your Source file to the project.
    • In "Solution Explorer" window right click the "Source Files" folder (the last one) > click "Add > "New Item…"
    • Copy Main.cpp > in the "Add New Item" wizard delete "FileName.cpp" > paste > click Add. The source file Main.cpp will open in the main text editor but leave the file blank for now.
  5. Advertisement
Part 8
Part 8 of 18:

Installing GLUTx64 and GLEWx64 in the Project

  1. 1
    Configure "Properties Pages". In Solution Explorer, right click on the name of your project, that is GLUTx64-GLEWx64-0, and select Properties (the last one). Name in image is different, but it does'nt matter. In GLUTx64-GLEWx64-0 Property Pages wizard, .
  2. 2
    Add dll files paths (addresses) to "System Variables". In Windows search text field (bottom left of the screen) type envir > hit Enter. "System Properties" wizard is thrown.
    • Select the "Advanced" tab from the top bar > click Environment Variables.... "Environment Variables" wizard is thrown.
    • Double click the "Path" (or "PATH") Variable in the "System Variables" section. "Edit environement variable" wizard is thrown.
    • Copy C:\GL\GLUTbin\bin\x64 > click New > Paste.
    • Copy C:\GL\GLEWbin\bin\Release\x64 > click New > Paste.
    • Click OK in all 3 wizards.
    • Close Visual Studio > in thrown wizard asking "Save changes to the following items?" click Save.
    • Restart your PC > open Visual Studio. In "Open recent" list, click "GLUTx64-GLEWx64-0.sln", the first one. Now your project is open ready for test.
  3. Advertisement
Part 9
Part 9 of 18:

Testing and Correcting project SDLx64-GLEWx64-0

  1. 1
    Test your project. Right click on following link and select Open Link in New Window badprog. Scroll down the page and find section Testing the setup (see image above). Copy code and paste in Main.cpp code area > in main menu select x64 > hit Ctrl+F5. You should see two windows: one black (the console) and other with white square in black background. If you do not see that, do bellow step.
  2. 2
    Correct errors if any. Files are missing. Copy C:\GLP\GLUTx64-GLEWx64-0 and paste in File Explorer Address Bar. You should see file you added Main.cpp, and 4 other files added by Visual Studio. If they are missing you missed add file Main.cpp. Go to Part 7, step 4, and add it now.
    • In "Error List" if you see error about
      • file with extension .h go to previous Part, step 1, sub step '"2. Additional Include Directories and follow instructions. Also check whether folders GLUTbin and GLEWbin exist in C:\GL.
      • file with extension .lib go to previous Part, step 1, sub step 3. Additional Library Directories, and follow instructions. Also to sub-step 4. Additional Dependencies.
      • "entry point must be defined" go to previous Part step 1, sub step '5. System and follow instructions.
    • Thrown wizard about System or file .dll go previous Part, step 2 and 3, and follow instructions.
    • For other errors, if you cannot correct them, close Visual Studio > delete project folder GLUTx64-GLEWx64 which lives in C:\GLP > open Visual Studio > repeat set up from Part 7. Good job.
  3. 3
    Tip: Even if in Property Pages main settings it is Platform: x64, click Configuration manager... and in Active solution platform: select x64.
  4. Advertisement
Part 10
Part 10 of 18:

Creating Project with GLUTx64-GLEWx64-0 Template

  1. 1
    Create template. Go to Visual Studio main menu and, while GLUTx64-GLEWx64-0 is open, click Project > Export Template... (see above image).
    • On Export template Wizard check Project Template, if it's not checked. Click Next >.
    • On Select Template Options, if Template name is GLUTx64-GLEWx64-0 it's okay. If it's not, type (or copy and paste) GLUTx64-GLEWx64-0
    • Click Finish.
    • Template has been created. Close thrown window with template's path.
  2. 2
    Create project. In Visual Studio main menu > Click File > New > Project....
    • In Create a new project wizard, in templates list, select (if necessary scroll down the list) GLUTx64-GLEWx64-0 > click Next.
    • In Configure your new project wizard, in "'Project name"' is GLUTx64-GLEWx64-01 it's okay. If it's not, type (or copy and paste) GLUTx64-GLEWx64-01
    • If Location is C:\GLP, it's okay. If it's not, copy C:\GLP, and paste.
    • Be sure Place solution and project in the same directory is checked.
    • Click Create.
    • In Visual Studio's GUI main menu, select x64 > hit Ctrl+F5.
    • TIP. When you create project with this template remember in Visual Studio GUI's main menu select x64.
  3. Advertisement
Part 11
Part 11 of 18:

Installing CMake

  1. 1
    Compiling a library from the source code guarantees that the resulting library is perfectly tailored for your CPU/OS, a luxury pre-compiled binaries don't always provide. It is also important that binaries you get target x64 platform.
  2. 2
    Create folders GL and GLP. Open Windows's File Explorer > Navigate to disk (directory) C.
    • If folders GL and GLP exist it's okay.
    • If they do not, right click in empty area > select New > Folder > type GL > hit Enter. By same way create folder GLP.
  3. 3
    Download CMake. Right-click on following address and select Open Link in New Window https://cmake.org/download/. Scroll down the page and find "Latest Release (3.26.0)", (or latest). In second "Platform" list, find (see image above) "Windows x64 ZIP" and click the beside entry cmake-3.26.0-windows-x86_64.zip (or latest) > in opening wizard select Save file.
  4. 4
    Copy and unzip the zip folder.
    • If the downloaded folder doesn't contain line with stripes (unzipped folder) click it > right click > Copy.
    • (If downloaded folder's icon contains vertical line with stripes (zipped folder), double click it for get unzipped folder, (or alternatively, click folder > right click > in drop-down menu select Extract all).
      • When unzipping (extracting files) is finished, click unzip folder cmake-3.26.0-windows-x86_64.zip (or latest) > right click > Copy.)
    • Go to drive (directory) C: > GL > right click > Paste.
    • (Alternatively click unzipped folder "cmake-3.26.0-windows-x86_64" and drag into folder "GL").
    • When copying is finished click folder "cmake-3.26.0-windows-x86_64" > right click > select "Rename" > type CMake > hit Enter > double click it > double click folder bin > inside you should see CMake's logo next to file name cmake-gui > double click this file. Now on your screen you have CMake GUI.
    • Each time you need CMake, navigate to C:\ > GL > double click folder CMake > double click "bin" > double click file cmake-gui (the one with CMake's logo).
  5. Advertisement
Part 12
Part 12 of 18:

Downloading Source FreeGLUT and Source GLEW

  1. 1
    Download FreeGLUT source. Right-click on following address and select Open Link in New Window https://github.com/FreeGLUTProject/freeglut/releases/tag/v3.2.2. Below (see above image) Assets, click "Source code (zip)".
    • After downloading click "freeglut-3.2.2.zip" (or latest version) > in thrown window click "freeglut-3.2.2" > right click > Copy (Alternatively if "Copy to ..." option exists instead click it > copy C:\GL\ and paste in thrown wizard > click OK).
      • If you see letter Z (zipped) on folder's icon, double click it for get folder without Z (unzipped).
    • Go to C:\ > GL > right click > Paste.
    • Click on folder "freeglut-3.2.2" > right click > click "Rename" > type (or copy and paste): GLUTsrc > hit Enter.
  2. 2
    Download GLEW source. Right-click on following address and select Open Link in New Window http://glew.sourceforge.net/. Beside (see image above) Source click ZIP.
    • In downloaded window click folder glew-2.1.0 (or latest) > right click > Copy.
    • Navigate to C:\ > GL. Right click > Paste. Rename folder to GLEWsrc > hit Enter. Now in folder GL you have folders GLUTsrc and GLEWsrc.
  3. Advertisement
Part 13
Part 13 of 18:

Compiling Source FreeGLUT and Source GLEW

  1. 1
    Compile FreeGLUT by CMake and Visual Studio.
  2. 2
    Compile GLEW by CMake and Visual Studio. Go to CMake GUI.
    • Copy (attention: do not copy any space)C:/GL/GLEWsrc/build/cmake and paste in first text field.
    • Copy (attention: do not copy any space)C:/GL/GLEWsrc/build and paste in second text field.
    • Configure and generate. In CMake GUI, click Configure > in wizard Create Directory click Yes > in wizard "Specify the generator for this project" click Finish.
      • When, in CMake GUI, you read: "Configuring done", click Generate. You should read: "Generating done".
    • Navigate to C:\GL\GLEWsrc\build . Double click "glew.sln", or "glew", or "ALL_BUILD.vcxproj". An instance of Visual Studio appears. Wait until in main menu Build entry appears. Click Build > Build Solution (the first option).
      • Wait till you read the last line in "Output" window: ========== Build: 6 succeeded, 0 failed, 0 up-to-date, 2 skipped" ==========
        • Number of "succeeded" changes in glew versions.
    • Copy C:\GL\GLEWsrc\build\lib\Debug and paste in File Explorer's Address Bar > hit Enter. Inside you should see file glew32d.lib among other files.
    • Close Cmake GUI.
  3. Advertisement
Part 14
Part 14 of 18:

Creating Project GLUTsrc-GLEWsrc-0

  1. 1
    Create empty project.
    • If Visual Studio is not open. Open it > click Create a new project > find (see image above, if necessary scroll down the list. Icon is different than in image, it doesn't matter though) Empty Project Start from scratch with C++ for Windows. Provides no starting files., click it > click Next.
      • In Configure your new project wizard, for "Project name", type (or copy and paste) GLUTsrc-GLEWsrc-0
      • "Location" should be C:\GLP. If it's not, delete everything, copy C:\GLP\ and paste.
      • Check "Place solution and project in the same directory".
      • Click Create.
      • Wait till Visual Studio instance appears.
    • If it is open. Click File > New > Project… . The rest as above.
  2. 2
    Add your Source file to the project.
    • In "Solution Explorer" window right click the "Source Files" folder (the last one) > click "Add" > "New Item…"
    • Copy Main > in the "Add New Item" wizard delete "FileName" > paste > click Add. The file will open in the main text editor but leave the file blank for now.
  3. Advertisement
Part 15
Part 15 of 18:

Installing GLUTsrc and GLEWsrc on the Project

  1. 1
    Configure "Properties pages". In Solution Explorer wizard, right click Project's name that is GLUTsrc-GLEWsrc > select Properties. Name in image is different, but it doesn't matter. .
  2. 2
    Add dll files paths (addresses) to "System Variables". In Windows search text field (bottom left of the screen) type envir > hit Enter. "System Properties" wizard is thrown.
    • Select the "Advanced" tab from the top bar > click Environment Variables.... "Environment Variables" wizard is thrown.
    • Double click the "Path" (or "PATH") Variable in the "System Variables" section. "Edit environment variable" wizard is thrown.
    • Copy C:\GL\GLUTsrc\build\bin\Debug > click New > Paste.
    • Copy C:\GL\GLEWsrc\build\bin\Debug > click New > Paste.
    • Click OK in all 3 wizards.
    • Close Visual Studio > in thrown wizard asking "Save changes to the following items?" click Save.
    • Restart your PC > open Visual Studio. In "Open recent" list, click "GLUTsrc-GLEWsrc-0.sln", the first one. Now your project is open ready for test.
  3. Advertisement
Part 16
Part 16 of 18:

Testing and Correcting Project GLUTsrc-GLEWsrc-0

  1. 1
    Test your project. Right click on following link and select Open Link in New Window badprog. Scroll down the page and find section Testing the setup (see image above). Copy code and paste in Main.cpp code area > in main menu select x64 > hit Ctrl+F5. You should see two windows: one black (the console) and other with white square in black background. If you do not see that, do bellow step.
  2. 2
    Correct errors if any. Files are missing. Copy GLUTsrc-GLEWsrc-0 and paste in File Explorer Address Bar. You should see file you added Main.cpp, and 4 other files added by Visual Studio. If they are missing you missed add file Main.cpp. Go to Part 14, step 2, and add it now.
    • In "Error List" if you see error about
      • file with extension .h go to previous Part, step 1, sub step 1, sub step 2. Additional Include Directories and follow instructions. Also check whether folder SDLbin exists in C:\GL. Also check whether folders GLUTsrc and GLEWsrc exist in C:\GL.
      • file with extension .lib go to previous Part, step 1, sub step 3. Additional Library Directories, and follow instructions. Also to step 1, sub step 4. Additional Library Directories.
      • "entry point must be defined" go to previous Part, step 1, sub step 5. System and follow instructions.
    • Thrown wizard about System or file .dll go to previous Part, steps 2 and 3, and follow instructions.
    • For other errors, if you cannot correct them, close Visual Studio > delete project folder GLUTsrc-GLEWsrc-0 which lives in C:\GLP > open Visual Studio > repeat set up from Part 14. Good job.
  3. Advertisement
Part 17
Part 17 of 18:

Creating Project with GLUTsrc-GLEWsrc-0 Template

  1. 1
    Create template. Go to Visual Studio main menu and, while GLUTsrc-GLEWsrc-0 is open, click Project > Export Template... (see above image).
    • On Export template Wizard check Project Template, if it's not checked. Click Next >.
    • On Select Template Options, in Template name: if name is GLUTsrc-GLEWsrc-0 it's okay. If not, copy it and paste in text box > click Finish.
    • Template has been created. Close thrown window with template's path.
  2. 2
    Create project.
    • In Visual Studio main menu select x64.
    • Click File > New > Project....
    • In Create a new project wizard, in templates list, select (if necessary scroll down the list) GLUTsrc-GLEWsrc-0 > click Next.
    • In Configure your new project wizard, in "'Project name"', if name is GLUTsrc-GLEWsrc-01, it's okay. If not copy it and paste in text field.
    • Copy C:\GLP, and paste in Location text field.
    • Be sure Place solution and project in the same directory is checked.
    • Click Create.
    • In Visual Studio GUI's main menu select x64 (next to Debug) > hit Ctrl+F5. Good job
    • TIP: Remember, in every project you create with this template, select x64 (next to Debug) in Visual Studio's GUI.
  3. Advertisement
Part 18
Part 18 of 18:

Choosing Set Up

  1. 1
    In this tutorial you learn 3 was to set up FreeGLUT and GLEW in Project with Visual Studio.
    • Set up binaries x86 (32 bits). It's the easiest. You should start learning set up from here.
    • Set up binaries x64 (64 bits). It targets x64 platform. Choose it only when you have specific reason for doing so.
    • Set up compiled source (also 64 bits). Targets x64 too.The most difficult. The best though.

About This Article

wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, 14 people, some anonymous, worked to edit and improve it over time. This article has been viewed 44,329 times.
How helpful is this?
Co-authors: 14
Updated: March 21, 2023
Views: 44,329
Advertisement