How to Set Up an OpenGL FreeGLUT GLEW Template Project in Visual Studio

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 loading libraries (such as GLEW). This guide will help you get over the...
Method 1 of 7:

Downloading freeGLUT and GLEW

  1. How to Set Up an OpenGL FreeGLUT GLEW Template Project in Visual Studio Picture 1How to Set Up an OpenGL FreeGLUT GLEW Template Project in Visual Studio Picture 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. Create a new folder called GL. In directory (disk) C:, right click > select New > Folder > type GL > hit Enter.
  3. Download the application GLEW. Right-click on following link and select Open Link in New Window http://glew.sourceforge.net. Below the Downloads heading, click Windows 32-bit and 64-bit.
    1. In downloading window click folder glew-2.1.0 > right click > select Copy.
    2. Navigate to C: > GL. Right click > select Paste. Click on name glew-2.1.0 and rename it to glew.
    3. If folder glew-2.1.0-win32 is downloaded, double click it to get glew-2.1.0.
  4. Download the 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 freeglut 3.0.0 MSVC Package click Download freeglut 3.0.0 for MSVC.
    1. In downloading window right click folder freeglut
    2. Navigate to C: > GL. Right click > select Paste.
    3. Now in folder GL you have two folders: freeglut and glew.
Method 2 of 7:

Creating a Visual Studio Project

  1. Create an empty project.
    1. With Visual Studio 2017
      1. In V.S. main menu, click File. Then go to New > Project…
      2. In the left part of the new project window, click Visual C++ if it is not clicked.
      3. In the center of the screen click Empty Project.
      4. Below that, find the Name text box, type Project-0.
      5. Next to Location text box, click Browse... and navigate to C: > GL.
      6. Click Select a folder. The Location in New Project window is C:GL.
      7. Make sure the Create directory for solution box is not checked.
      8. Click OK.
    2. With Visual Studio 2019
      1. If it's not opened. Open it > Click Create a new project > Empty Project > Next.
      2. In Configure your new project wizard for "Project name" type: Project-0.
      3. Next to "Location" text field click .... Navigate to C: > GL > click Select folder. Now "Location" is C:GL.
      4. Check "Place solution and project in the same directory" > click Create.
      5. Wait till Visual Studio 2019 instance appears.
      6. If it's opened. Click File > New > Project… > Create a new project > Empty Project > Next. The rest as above.
  2. Add your source file to the Project.
    1. In the solution explorer window, right click the Source Files folder (the last one) > click Add > New Item….
    2. In the Add New Item - Project-0 window, click C++ File (.cpp) (the first one) from the middle of the window. In the Name text box, type Main.cpp.
    3. The Location is C:GLProject-0.
    4. Click the Add button. The file will open in the main text editor but leave the file blank for now.
Method 3 of 7:

Installing freeGLUT and GLEW on a Project

  1. Configure "Additional Include Directories"
    1. In Solution Explorer, right click on the name of your project, that is Project-0, and select Properties. Leave default settings: Configuration: Active(Debug), and Platform: Active(Win32).
      How to Set Up an OpenGL FreeGLUT GLEW Template Project in Visual Studio Picture 2How to Set Up an OpenGL FreeGLUT GLEW Template Project in Visual Studio Picture 2
    2. Open the C/C++ drop-down menu. Click General > Additional Include Directories > click the down arrow at the right of the field > click in the drop down menu.
      How to Set Up an OpenGL FreeGLUT GLEW Template Project in Visual Studio Picture 3How to Set Up an OpenGL FreeGLUT GLEW Template Project in Visual Studio Picture 3
    3. Add freeglutinclude folder: Copy C:GLfreeglutinclude > in Additional Include Directories wizard, click first icon > paste.
      How to Set Up an OpenGL FreeGLUT GLEW Template Project in Visual Studio Picture 4How to Set Up an OpenGL FreeGLUT GLEW Template Project in Visual Studio Picture 4
    4. Add glewinclude folder: Copy C:GLglewinclude > click again first icon > paste > on Additional Include Directories wizard click OK .
  2. Configure linker "Additional Library Directories"
    1. Open the Linker drop-down menu, and click General. Click Additional Library Directories entry > down arrow at the right of the field > in the drop-down menu.
      How to Set Up an OpenGL FreeGLUT GLEW Template Project in Visual Studio Picture 5How to Set Up an OpenGL FreeGLUT GLEW Template Project in Visual Studio Picture 5
    2. Add the freeglutlib folder: Copy C:GLfreeglutlib > in Additional Library Directories wizard click first icon > paste.
    3. Add the glewlibReleaseWin32 folder: Copy C:GLglewlibReleaseWin32 > click first icon > paste > in Additional Library Directories wizard click OK.
  3. Configure linker "Additional Dependencies"
    1. In the Linker drop-down menu, click Input > click the Additional Dependencies entry > the down arrow at the right of the field > click in the drop-down menu.
      How to Set Up an OpenGL FreeGLUT GLEW Template Project in Visual Studio Picture 6How to Set Up an OpenGL FreeGLUT GLEW Template Project in Visual Studio Picture 6
    2. Copy freeglut.lib; glew32.lib; opengl32.lib and paste on the top-most text box of the Additional Dependencies wizard > click OK in the Additional Dependencies wizard.
      How to Set Up an OpenGL FreeGLUT GLEW Template Project in Visual Studio Picture 7How to Set Up an OpenGL FreeGLUT GLEW Template Project in Visual Studio Picture 7
  4. Set linker "SubSystem" to "Console"
    1. In the Linker drop-down menu, click System > SubSystem. Click the down arrow and select Console(/SUBSYSTEM:CONSOLE) from the dropdown menu. Click Apply, then OK on the Project Property Pages window.
  5. Copy freeglut.dll file and paste to Project-0 folder.
    1. Navigate to C: > GL > freeglut > bin. Inside bin folder click freeglut.dll file > right-click > Copy.
    2. Navigate to C: > GL > Project-0. Right-click an empty area in Project-0 folder, and select Paste.
    3. The freeglut.dll file should now be in your project directory along with your Main.cpp file and a few other files created by Visual Studio.
  6. Copy glew32.dll file and paste to Project folder
    1. Navigate to C: > GL > glew > bin > Release > Win32. Click glew32.dll > right-click > Copy.
    2. Navigate to C: > GL > Project-0. Right-click an empty area in Project-0 folder, and select Paste.
    3. The glew32.dll file should now be in Project-0 folder along with Main.cpp, freeglut.dll, and 4 other files created by Visual Studio.
  7. How to Set Up an OpenGL FreeGLUT GLEW Template Project in Visual Studio Picture 8How to Set Up an OpenGL FreeGLUT GLEW Template Project in Visual Studio Picture 8
    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 > 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.
  8. Correct any errors. In "Error List" if you see error about
    1. file with extension .h go to part (Method) 3, step 1, "Configure the "Additional Include Directories"" and follow instructions.
    2. file with extension .lib go to part (Method) 3, step 2, "Configure the linker "Additional Library Directories"", and follow instructions. Also to step 3, "Configure the linker "Additional Library Directories"".
    3. "entry point must be defined" go to step 4, Set linker "SubSystem" to "CONSOLE" and follow instructions.
    4. file .dll go to step 5, "Copy freeglut.dll file and paste to Project-0 folder" and follow instructions.
    5. For other errors, if you cannot correct them, close Visual Studio > delete project folder Projetc-0 which lives in C:GL > open Visual Studio > repeat set up from part Method 2. Good job.
Method 4 of 7:

Creating a Project with OpenGL-freeGLUT-GLEW Template

  1. Create template. Go to Visual Studio main menu and, while Project-0 is open, click Project > Export Template.... On Export template Wizard check Project Template, if it's not checked. Click Next >. On Select Template Options, in Template name text box type: OpenGL-freeGLUT-GLEW. Click Finish. The Template has been created.
  2. Create project.
    1. With V.S. 2017. Click File > New > Project....
      1. On the New Project window, click template: OpenGL-freeGLUT-GLEW.
      2. In Name text field, type: Project-1. Be sure Create directory for solution is unchecked. Click OK.
    2. With V.S. 2019. Click File > New > Project....
      1. In Create a new project wizard scroll down the list of templates and select OpenGL-freeGLUT-GLEW > click Next.
      2. In Configure your new project wizard, in "Project name" text field type Project-1.
      3. Location should be C:GL. If it's not, click ... at the end of the field > navigate C:GL > Folder should be GL > click Select a folder. Now Location is C:GL.
      4. Be sure Place solution and project in the same directory is checked. Click Create.
    3. In the Solution Explorer, double click Source Files > double click ++Main.cpp. Its code appears in the code area. Run it. If code does not appear, right click ++Main.cpp > click Exclude From Project. Now create new Main.cpp.
  3. Add freeglut.dll file to new project-folder
    1. Navigate to C: > GL > Project-0 > click file freeglut.dll > right click > click Copy.
    2. Navigate to C: > GL > Project-1 > click on empty area > right click > click Paste.
    3. Now file freeglut.dll is in folder Project-1 among Main.cpp and other 4 files.
  4. Add glew32.dll file to new project-folder
    1. Navigate to C: > GL > Project-0 > click file glew32.dll > right click > click Copy.
    2. Navigate to C: > GL > Project-1 > click on empty area > right click > click Paste.
    3. Now the file glew32.dll is in the folder Project-1 among freeglut.dll, Main.cpp and other 4 files.
  5. Test your project as above. Good job!
Method 5 of 7:

Create project to target x64 platform

  1. Create empty project as above with name Project-2, and add Main.cpp file.
  2. SDLproject's Properties settings. Go to "Solution Explorer" > right click on the name of your project that is Project-2 > select "Properties". In Platform: entry, choose x64 > Click Configuration manager...
    1. In Active solution platform: select x64
    2. In Platform entry select x64
    3. Click Close
  3. Additional Include Directories. As with targeting x86 platform, see above Method 3, step 1.
  4. Additional Library Directories. Open the "Linker" drop-down menu, and click "General". Click "Additional Library Directories" entry > down arrow at the end of the field > "Edit" in the drop-down menu.
    1. Copy this C:GLfreeglutlibx64 > in Additional Library Directories click first icon > paste.
    2. Copy this C:GLglewlibReleasex64 > click first icon > paste > click OK.
  5. Additional Dependencies. As with targeting x86 platform, see above Method 3, step 3.
  6. Subsystem. As with targeting x86 platform, see above Method 3, step 4.
  7. Copy dll files and paste into Project-2.
    1. Copy freeglut.dll file and paste into Project-2. In Windows's "File Explorer" navigate to
      1. C:GLfreeglutbinx64. In "x64" folder click "freeglut.dll" file > right-click > "Copy".
      2. C: > GL > Project-2. Right-click on empty area in "Project-2" folder, and select "Paste".
    2. Copy glew32.dll file and paste into Project-2. In Windows's "File Explorer" navigate to
      1. C: > GL > glew > bin > Release > x64. In "x64" folder click "glew32.dll" file > right-click > "Copy".
      2. C: > GL > Project-2. Right-click on empty area in "Project-2" folder, and select "Paste".
  8. Test your project and correct errors if any. As with targeting x86 platform, see above, Method 3 steps 7 and 8.
  9. Tip: Even if in Property Pages main settings it is Platform: x64, click Configuration manager... and in Active solution platform: select x64.
  10. Create template. As in Method 4.
    1. Tip: In every project you create with it, select x64 (next to Debug) in Visual Studio's GUI.
Method 6 of 7:

Setting up Built FreeGLUT and Built GLEW

  1. In directory C, create folder GL. If folder with this name exists, close Visual Studio > in File Explorer > directory C > right click GL folder > select Delete > again right click > select New > Folder > type: GL > hit Enter.
  2. Install CMake. Right-click on following link and select Open Link in New Window Use CMake to Get Binaries from Source Code. Follow Method 1 Installing CMake.
  3. Download FreeGLUT source. Right-click on following address and select Open Link in New Window https://sourceforge.net/projects/freeglut/. Click Download
    1. In downloading window click zip folder freeglut-3.2.1 (or latest version) > right click > select Copy.
    2. In File Explorer navigate to C: > GL > right click > select Paste. Click twice on folder's name > delete name > type: freeglut > hit Enter.
  4. Download GLEW source. Right-click on following address and select Open Link in New Window http://glew.sourceforge.net/. Beside Source click ZIP.
    1. In download in window click folder glew-2.1.0 (or latest) > right click > Copy.
    2. Navigate to C: > GL. Right click > Paste. Click twice on folder's name and rename glew > hit Enter. Now in folder GL you have folders glew and freeglut.
  5. Build FreeGLUT by CMake and Visual Studio. Go to CMake GUI.
    1. Copy C:/GL/freeglut and paste in first text field.
    2. Copy C:/GL/freeglut/build and paste in second text field.
    3. Configure and generate. In CMake GUI, click Configure > in wizard Create Directory click Yes > select Visual Studio 16 2019 > click Finish.
      1. When, in CMake GUI, you read: "Configuring done", click Generate. You should read: "Generating done".
    4. Build your solution.
      1. Navigate to C: > GL > freeglut > build. Double click "freeglut.sln", or "freeglut", or "ALL_BUILD.vcxproj". An instance of Visual Studio appears. Wait until in main menu Build entry appears. Click it > "Build Solution".
      2. Wait till you read the last line in "Output" window: ========== Build: XX succeeded, 0 failed, 0 up-to-date, 1 skipped" ==========
        1. Number XX of "succeeded" changes in freeglut versions. Today (11-Feb-2020) is 28.
    5. Navigate to C:GLfreeglutbuildlibDebug. Inside you should see file freeglutd.lib among other two files.
  6. Build GLEW by CMake and Visual Studio. Follow above step but
    1. In first text field paste C:/GL/glew/build/cmake
    2. In second paste C:/GL/glew/build
    3. Navigate to C: > GL > glew > build. Double click "glew.sln", or "glew", or "ALL_BUILD.vcxproj".
    4. In V.S. Output wizard, number of succeeded today (31-1-2020) is 6, may change in later version though.
    5. Navigate to C: > GL > glew > build > lib > Debug. Inside you should see file glew32d.lib among two other files.
  7. Set up built FreeGLUT and built GLEW in project.
    1. Create empty project and add source file according to Method 2.
    2. Configure project's Properties. In Solution Explorer wizard, right click Project's name that is Project-0 > select Properties.
      1. (1) Project-0 Property Pages main menu. In Platform entry select x64 > click Configuration Manager....
        1. In Active solution platform: select x64.
        2. In Platform entry, x64 is automatically selected.
        3. Click Close.
      2. (2) Additional Include Directories. Click C/C++ > General > In beside menu select the first one, Additional Include Directories > click the down arrow at the end of the field > click Edit... > first icon > three dots ...
        1. Navigate to C: > GL > freeglut > include > click include > click Select a folder.
        2. Click again first icon > three dots > navigate to C: > GL > glew > include > click include > click Select a folder > click OK.
      3. (3) Additional Library Directories. Double click Linker > click General > Additional Library Directories > click the down arrow at the end of the field > click Edit... > first icon.
        1. Copy C:GLfreeglutbuildlibDebug and paste in upper-most text field.
        2. Click again first icon > copy C:GLglewbuildlibDebug and paste in upper-most text field > click OK.
      4. (4) Additional Dependencies. In Linker drop-down menu select Input > in beside menu select the first one, Additional Dependencies > click the down arrow at the end of the field > Edit... > copy opengl32.lib; freeglutd.lib; glew32d.lib and paste in Additional Dependencies wizard's upper-most text box > click OK.
      5. (5) Set System to SubSystem CONSOLE. In Linker drop-down menu select System > in beside menu select the first one, SubSystem > click the down arrow at the end of the field > select Console (/SUBSYSTEM:CONSOLE). Click Apply and OK.
    3. Copy files freeglutd.dll and glew32d.dll, and paste into Project-0 folder.
      1. Navigate to C:GLfreeglutbuildbinDebug. Click freeglutd.dll > right-click > Copy.
      2. Navigate to C: > GL > Project-0. Right-click an empty area in Project-0 folder, and select Paste.
      3. Navigate to C:GLglewbuildbinDebug. Click glew32d.dll > right-click > Copy.
      4. Navigate to C: > GL > Project-0. Right-click an empty area in Project-0 folder, and select Paste.
      5. Files freeglutd.dll and glew32d.dll should now be in Project-0 folder along with Main.cpp, and 4 other files created by Visual Studio.
  8. Test your project and correct errors if any. As above Method 3, steps 7 and 8.
  9. Create Template. As above Method 4 but in Visual Studio GUI, main menu select x64. Remember copy and paste dll files.
Method 7 of 7:

Choosing Set Up

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