GLUT (and probably GLEW) not working (followed install instructions)

Sorry for new thread but other thread was getting off topic....

I installed glut as like the readme.txt file said:

* Put the .dll in system32 directory
* put the .h file in "CodeBlocks\MinGW\include" and "CodeBlocks\MinGW\include\GL"
* put the .lib "CodeBlocks\MinGW\lib"

Restarted program and the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* Using the standard output for fprintf */
#include <stdio.h>
#include <stdlib.h>
/* Use glew.h instead of gl.h to get all the GL prototypes declared */
#include <glew.h>
/* Using the GLUT library for the base windowing setup */
#include <glut.h>

/* ADD GLOBAL VARIABLES HERE LATER */

int init_resources(void)
{
  /* FILLED IN LATER */
  return 1;
}

void onDisplay()
{
  /* FILLED IN LATER */
}

void free_resources()
{
  /* FILLED IN LATER */
}

int main(int argc, char* argv[])
{
  /* Glut-related initialising functions */
  glutInit(&argc, argv);
  glutInitContextVersion(2,0);
  glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH);
  glutInitWindowSize(640, 480);
  glutCreateWindow("My First Triangle");

  /* Extension wrangler initialising */
  GLenum glew_status = glewInit();
  if (glew_status != GLEW_OK)
  {
    fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status));
    return EXIT_FAILURE;
  }

  /* When all init functions run without errors,
  the program can initialise the resources */
  if (1 == init_resources())
  {
    /* We can display it if everything goes OK */
    glutDisplayFunc(onDisplay);
    glutMainLoop();
  }

  /* If the program exits in the usual way,
  free resources and exit with a success */
  free_resources();
  return EXIT_SUCCESS;
}


... does not work and gives errors:

http://imgur.com/H2R00O9

I would really like to know:
* If there is any way to simply copy and paste build errors like normal text, and if not, why the hell not?
* If the code I quoted above actually does work or not. (its from: http://en.wikibooks.org/wiki/OpenGL_Programming#The_basics_arc)
* If none of the above, what have the install instructions not said how to do?
The errors seem to indicate that you haven't actually linked the static library (.lib) with your project dependencies.

If that's the case, navigate to:

Projects > Build Options > Linker Settings > Link Libraries

I've never used CodeBlocks - I found the above through search results, so I'm sorry if it's incorrect.
Last edited on
Thanks, I went into the "linker" tab in build settings, clicked "add -> new" and then located the glut.lb where I installed it. The same errors as before still occur though. The errors are NOT in the code im using though, they are in "glut.h" (at least it opens those files when I run and goes to a certain point). Is it therefore the case that I downloaded a dodgy/not working version of GLUT?
As long as you're getting "undefined reference" errors, it means something isn't linking properly.


It's been a while since I worked with something other than pure OpenGL.

To install GLEW properly on windows for CodeBlocks:

1.) move "bin/glew32.dll" to "%SystemRoot%/system32"
2.) move "lib/glew32.lib" to "CodeBlocks/MinGW/lib"
3.) move "include/GL/glew.h" to "CodeBlocks/MinGW/include/GL"
4.) move "include/GL/wglew.h" to "CodeBlocks/MinGW/include/GL"

To install GLUT properly on windows for CodeBlocks:

1.) move "glut32.dll" to "%SystemRoot%/system32"
2.) move "glut.h" to "CodeBlocks/MinGW/include/GL"
3.) move "glut32.lib" to "CodeBlocks/MinGW/lib"


And then, of course, you need to add linker dependencies for both libraries.
Topic archived. No new replies allowed.