compiled program cannot find freeglut.dll

DJDragon430 picture DJDragon430 · May 29, 2013 · Viewed 17.9k times · Source

I'm new to this site, and relatively new to programming. I've been doing some C++ programming for a while using Visual Studio 2010, and I wanted to get into OpenGL, so I bought the OpenGL Superbible to get started. I've gotten stuck on the second chapter's "simple" project. After hours of research I've been able to download all the necessary files to use freeGLUT and GLtools. I've made sure that everything is in the right place for the program to work. Now, it appears as though everything has been worked out... except for one odd problem.

I was instructed that I needed to place freeglut.dll into Windows\System32, so I did. The project will build now, but when I go to run it, it tells me

"The program can't start because freeglut.dll is missing from your computer. Try reinstalling the program to fix this problem."

Now, I am certain that freeglut.dll is in Windows\System32 as it should be, so what's the problem? how do I solve it?

Here's the original code from the book:

#include "../../shared/gltools.h"  //OpenGL toolkit

//////////////////////////////////////////////
//called to draw scene

void RenderScene(void)
{
    // clear the window with current clearing color
    glClear(GL_COLOR_BUFFER_BIT);

 //Flush drawing commands
    glFlush();
}
////////////////////////////////////////////////////////
//set up the rendering state
void SetupRC(void)
{
    glClearColor(0.0f , 0.0f, 1.0f, 1.0f );
}
///////////////////////////////////////////////////////////
//main program entry point
void main(void)
int main(int argc, char* argv[])
    {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
    glutCreateWindow("Simple");
    glutDisplayFunc(RenderScene);

    SetupRC();
    glutMainLoop();
    return 0;
    }

This is the code that actually compiled, but would not run (it's a bit of a mess from all the conflicting data I got from different resources):

 #include <stdio.h>
 #include <stdlib.h>
 #include <windows.h>
 #include <GLTools.h>
 #include <gl/GLUT.h>
 //called to draw scene

 void RenderScene(void)
 {
// clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT);

glFlush();
 }

 //set up the rendering state
 void SetupRC(void)
 {
glClearColor(0.0f , 0.0f, 1.0f, 1.0f );
 }

 //void main(void)
 int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
glutCreateWindow("Simple");
glutDisplayFunc(RenderScene);

SetupRC();
glutMainLoop();
return 0;
}

Answer

ScottMcP-MVP picture ScottMcP-MVP · May 29, 2013

Try putting the DLL in the same folder as your exe file. The advice to put it in Windows\System32 predates a lot of newer Windows security restrictions.