argc - cant access memory

Hadron
2007-07-09T13:26:35Z

I recently compiled and executed an opengl programming guide (redbook)
example, hello.c, successfully. However, when I try to debug it under
GUD I get

,----
| #0 main (argc=Cannot access memory at address 0x2d
| ) at hello.c:93
`----

The code can be found here:

http://opengl-redbook.com/code/

but is pasted below for convenience.

It is compiled using the following Linux based makefile:

,----
| CC=gcc
| COMPILE.c=$(CC) $(CFLAGS) -c
| LINK.c=$(CC) $(CFLAGS) $(LDFLAGS)
| LDLIBS=$(EXTRALIBS)
| CFLAGS= -std=c99 -pedantic -Wall -D_GNU_SOURCE -g
|
| GLUT = -lglut
| EXTRALIBS = $(GLUT) -lGLU -lGL -lXmu -lXext -lX11 -lm
|
| PROGS = \
| aaindex aargb accanti accpersp alpha3D \
| alpha bezcurve bezmesh bezsurf blendeqn \
| checker clip colormat combiner cubemap \
| cube dof double drawf feedback \
| fogcoord fogindex fog font hello \
| image light lines list material \
| mipmap model movelight multisamp multitex \
| mvarray pickdepth picksquare planet pointp \
| polyoff polys quadric robot scene \
| select shadowmap smooth stencil stroke \
| surface surfpoints teapots tesswind tess \
| texbind texgen texprox texsub texture3d \
| texturesurf torus trim unproject varray \
| wrap
|
| IMAGING_SUBSET = colormatrix colortable convolution histogram minmax blendeqn
|
| all: $(PROGS)
|
| clean:
| rm -f $(PROGS)
`----

The code is:

,----
| /*
| * hello.c
| * This is a simple, introductory OpenGL program.
| */
| #include <GL/glut.h>
| #include <stdlib.h>
|
| void display(void)
| {
| /* clear all pixels */
| glClear (GL_COLOR_BUFFER_BIT);
|
| /* draw white polygon (rectangle) with corners at
| * (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
| */
| glColor3f (1.0, 1.0, 1.0);
| glBegin(GL_POLYGON);
| glVertex3f (0.25, 0.25, 0.0);
| glVertex3f (0.75, 0.25, 0.0);
| glVertex3f (0.75, 0.75, 0.0);
| glVertex3f (0.25, 0.75, 0.0);
| glEnd();
|
| /* don't wait!
| * start processing buffered OpenGL routines
| */
| glFlush ();
| }
|
| void init (void)
| {
| /* select clearing color */
| glClearColor (0.0, 0.0, 0.0, 0.0);
|
| /* initialize viewing values */
| glMatrixMode(GL_PROJECTION);
| glLoadIdentity();
| glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
| }
|
| /*
| * Declare initial window size, position, and display mode
| * (single buffer and RGBA). Open window with "hello"
| * in its title bar. Call initialization routines.
| * Register callback function to display graphics.
| * Enter main loop and process events.
| */
| int main(int argc, char** argv)
| {
| glutInit(&argc, argv);
| glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
| glutInitWindowSize (250, 250);
| glutInitWindowPosition (100, 100);
| glutCreateWindow ("hello");
| init ();
| glutDisplayFunc(display);
| glutMainLoop();
| return 0; /* ANSI C requires main to return int. */
| }
`----

It is not on all lines in main that I get this error.

Ideas?