OpenGL X11 app
I've struggled a lot over the last few days trying to build glxgears.c and at this point I'd just like to know if people out there have some good documentation on getting an X11 OpenGL context working.
# gcc -I/usr/X11R6/include -L/usr/X11R6/lib glxgears.c
glxgears.c:501:2: warning: no newline at end of file
/var/tmp//ccuhcfJ3.o(.text+0x74): In function `gear':
: undefined reference to `glShadeModel'
/var/tmp//ccuhcfJ3.o(.text+0x91): In function `gear':
: undefined reference to `glNormal3f'
/var/tmp//ccuhcfJ3.o(.text+0x9e): In function `gear':
: undefined reference to `glBegin'
/var/tmp//ccuhcfJ3.o(.text+0xf5): In function `gear':
: undefined reference to `sin'
/var/tmp//ccuhcfJ3.o(.text+0x11a): In function `gear':
: undefined reference to `cos'
/var/tmp//ccuhcfJ3.o(.text+0x12c): In function `gear':
: undefined reference to `glVertex3f'
/var/tmp//ccuhcfJ3.o(.text+0x159): In function `gear':
: undefined reference to `sin'
/var/tmp//ccuhcfJ3.o(.text+0x17e): In function `gear':
: undefined reference to `cos'
... (this keeps going for some time) ...
/var/tmp//ccuhcfJ3.o(.text+0x1bdb): In function `main':
: undefined reference to `XCloseDisplay'
Exit 1
June 15, 2006 05:38 PM
I did get fewer errors this time. I'll post the glxgears source if you think it's a problem with the code I downloaded.
gcc -lX11 -lGL -lm glxgears.c
glxgears.c:36:22: X11/Xlib.h: No such file or directory
glxgears.c:37:24: X11/keysym.h: No such file or directory
glxgears.c:38:19: GL/gl.h: No such file or directory
glxgears.c:39:20: GL/glx.h: No such file or directory
glxgears.c:83: error: syntax error before "view_rotx"
glxgears.c:83: warning: data definition has no type or storage class
glxgears.c:84: error: syntax error before "gear1"
glxgears.c:84: warning: data definition has no type or storage class
glxgears.c:85: error: syntax error before "angle"
glxgears.c:85: warning: data definition has no type or storage class
glxgears.c:100: error: syntax error before "inner_radius"
glxgears.c: In function `gear':
glxgears.c:103: error: syntax error before "i"
glxgears.c:108: error: `r0' undeclared (first use in this function)
glxgears.c:108: error: (Each undeclared identifier is reported only once
glxgears.c:108: error: for each function it appears in.)
glxgears.c:108: error: `inner_radius' undeclared (first use in this function)
glxgears.c:109: error: `r1' undeclared (first use in this function)
glxgears.c:109: error: `outer_radius' undeclared (first use in this function)
glxgears.c:109: error: `tooth_depth' undeclared (first use in this function)
glxgears.c:110: error: `r2' undeclared (first use in this function)
glxgears.c:112: error: `da' undeclared (first use in this function)
glxgears.c:112: error: `teeth' undeclared (first use in this function)
glxgears.c:114: error: `GL_FLAT' undeclared (first use in this function)
glxgears.c:119: error: `GL_QUAD_STRIP' undeclared (first use in this function)
glxgears.c:120: error: `i' undeclared (first use in this function)
glxgears.c:122: error: `width' undeclared (first use in this function)
glxgears.c:133: error: `GL_QUADS' undeclared (first use in this function)
glxgears.c:185: error: `u' undeclared (first use in this function)
glxgears.c:186: error: `v' undeclared (first use in this function)
glxgears.c:187: error: `len' undeclared (first use in this function)
glxgears.c:213: error: `GL_SMOOTH' undeclared (first use in this function)
glxgears.c: In function `draw':
glxgears.c:230: error: `GL_COLOR_BUFFER_BIT' undeclared (first use in this function)
glxgears.c:230: error: `GL_DEPTH_BUFFER_BIT' undeclared (first use in this function)
glxgears.c: In function `reshape':
glxgears.c:263: error: syntax error before "h"
glxgears.c:265: error: `GLint' undeclared (first use in this function)
glxgears.c:265: error: syntax error before "width"
glxgears.c:266: error: `GL_PROJECTION' undeclared (first use in this function)
glxgears.c:268: error: `h' undeclared (first use in this function)
glxgears.c:269: error: `GL_MODELVIEW' undeclared (first use in this function)
glxgears.c: In function `init':
glxgears.c:278: error: syntax error before "pos"
glxgears.c: At top level:
glxgears.c:279: error: syntax error before "red"
glxgears.c:279: warning: data definition has no type or storage class
glxgears.c:280: error: syntax error before "green"
glxgears.c:280: warning: data definition has no type or storage class
glxgears.c:281: error: syntax error before "blue"
glxgears.c:281: warning: data definition has no type or storage class
glxgears.c:283: warning: parameter names (without types) in function declaration
glxgears.c:283: warning: data definition has no type or storage class
glxgears.c:284: warning: parameter names (without types) in function declaration
glxgears.c:284: warning: data definition has no type or storage class
glxgears.c:285: warning: parameter names (without types) in function declaration
glxgears.c:285: warning: data definition has no type or storage class
glxgears.c:286: warning: parameter names (without types) in function declaration
glxgears.c:286: warning: data definition has no type or storage class
glxgears.c:287: warning: parameter names (without types) in function declaration
glxgears.c:287: warning: data definition has no type or storage class
glxgears.c:290: error: initializer element is not constant
glxgears.c:290: warning: data definition has no type or storage class
glxgears.c:291: warning: parameter names (without types) in function declaration
glxgears.c:291: warning: data definition has no type or storage class
glxgears.c:292: warning: parameter names (without types) in function declaration
glxgears.c:292: warning: data definition has no type or storage class
glxgears.c:293: error: syntax error before numeric constant
glxgears.c:294: warning: data definition has no type or storage class
glxgears.c:296: error: initializer element is not constant
glxgears.c:296: warning: data definition has no type or storage class
glxgears.c:297: warning: parameter names (without types) in function declaration
glxgears.c:297: warning: data definition has no type or storage class
glxgears.c:298: warning: parameter names (without types) in function declaration
glxgears.c:298: warning: data definition has no type or storage class
glxgears.c:299: error: syntax error before numeric constant
glxgears.c:300: warning: data definition has no type or storage class
glxgears.c:302: error: initializer element is not constant
glxgears.c:302: warning: data definition has no type or storage class
glxgears.c:303: warning: parameter names (without types) in function declaration
glxgears.c:303: warning: data definition has no type or storage class
glxgears.c:304: warning: parameter names (without types) in function declaration
glxgears.c:304: warning: data definition has no type or storage class
glxgears.c:305: error: syntax error before numeric constant
glxgears.c:306: warning: data definition has no type or storage class
glxgears.c:308: warning: parameter names (without types) in function declaration
glxgears.c:308: warning: data definition has no type or storage class
glxgears.c:309: error: syntax error before '}' token
Exit 1
gcc -lX11 -lGL -lm glxgears.c
glxgears.c:36:22: X11/Xlib.h: No such file or directory
glxgears.c:37:24: X11/keysym.h: No such file or directory
glxgears.c:38:19: GL/gl.h: No such file or directory
glxgears.c:39:20: GL/glx.h: No such file or directory
glxgears.c:83: error: syntax error before "view_rotx"
glxgears.c:83: warning: data definition has no type or storage class
glxgears.c:84: error: syntax error before "gear1"
glxgears.c:84: warning: data definition has no type or storage class
glxgears.c:85: error: syntax error before "angle"
glxgears.c:85: warning: data definition has no type or storage class
glxgears.c:100: error: syntax error before "inner_radius"
glxgears.c: In function `gear':
glxgears.c:103: error: syntax error before "i"
glxgears.c:108: error: `r0' undeclared (first use in this function)
glxgears.c:108: error: (Each undeclared identifier is reported only once
glxgears.c:108: error: for each function it appears in.)
glxgears.c:108: error: `inner_radius' undeclared (first use in this function)
glxgears.c:109: error: `r1' undeclared (first use in this function)
glxgears.c:109: error: `outer_radius' undeclared (first use in this function)
glxgears.c:109: error: `tooth_depth' undeclared (first use in this function)
glxgears.c:110: error: `r2' undeclared (first use in this function)
glxgears.c:112: error: `da' undeclared (first use in this function)
glxgears.c:112: error: `teeth' undeclared (first use in this function)
glxgears.c:114: error: `GL_FLAT' undeclared (first use in this function)
glxgears.c:119: error: `GL_QUAD_STRIP' undeclared (first use in this function)
glxgears.c:120: error: `i' undeclared (first use in this function)
glxgears.c:122: error: `width' undeclared (first use in this function)
glxgears.c:133: error: `GL_QUADS' undeclared (first use in this function)
glxgears.c:185: error: `u' undeclared (first use in this function)
glxgears.c:186: error: `v' undeclared (first use in this function)
glxgears.c:187: error: `len' undeclared (first use in this function)
glxgears.c:213: error: `GL_SMOOTH' undeclared (first use in this function)
glxgears.c: In function `draw':
glxgears.c:230: error: `GL_COLOR_BUFFER_BIT' undeclared (first use in this function)
glxgears.c:230: error: `GL_DEPTH_BUFFER_BIT' undeclared (first use in this function)
glxgears.c: In function `reshape':
glxgears.c:263: error: syntax error before "h"
glxgears.c:265: error: `GLint' undeclared (first use in this function)
glxgears.c:265: error: syntax error before "width"
glxgears.c:266: error: `GL_PROJECTION' undeclared (first use in this function)
glxgears.c:268: error: `h' undeclared (first use in this function)
glxgears.c:269: error: `GL_MODELVIEW' undeclared (first use in this function)
glxgears.c: In function `init':
glxgears.c:278: error: syntax error before "pos"
glxgears.c: At top level:
glxgears.c:279: error: syntax error before "red"
glxgears.c:279: warning: data definition has no type or storage class
glxgears.c:280: error: syntax error before "green"
glxgears.c:280: warning: data definition has no type or storage class
glxgears.c:281: error: syntax error before "blue"
glxgears.c:281: warning: data definition has no type or storage class
glxgears.c:283: warning: parameter names (without types) in function declaration
glxgears.c:283: warning: data definition has no type or storage class
glxgears.c:284: warning: parameter names (without types) in function declaration
glxgears.c:284: warning: data definition has no type or storage class
glxgears.c:285: warning: parameter names (without types) in function declaration
glxgears.c:285: warning: data definition has no type or storage class
glxgears.c:286: warning: parameter names (without types) in function declaration
glxgears.c:286: warning: data definition has no type or storage class
glxgears.c:287: warning: parameter names (without types) in function declaration
glxgears.c:287: warning: data definition has no type or storage class
glxgears.c:290: error: initializer element is not constant
glxgears.c:290: warning: data definition has no type or storage class
glxgears.c:291: warning: parameter names (without types) in function declaration
glxgears.c:291: warning: data definition has no type or storage class
glxgears.c:292: warning: parameter names (without types) in function declaration
glxgears.c:292: warning: data definition has no type or storage class
glxgears.c:293: error: syntax error before numeric constant
glxgears.c:294: warning: data definition has no type or storage class
glxgears.c:296: error: initializer element is not constant
glxgears.c:296: warning: data definition has no type or storage class
glxgears.c:297: warning: parameter names (without types) in function declaration
glxgears.c:297: warning: data definition has no type or storage class
glxgears.c:298: warning: parameter names (without types) in function declaration
glxgears.c:298: warning: data definition has no type or storage class
glxgears.c:299: error: syntax error before numeric constant
glxgears.c:300: warning: data definition has no type or storage class
glxgears.c:302: error: initializer element is not constant
glxgears.c:302: warning: data definition has no type or storage class
glxgears.c:303: warning: parameter names (without types) in function declaration
glxgears.c:303: warning: data definition has no type or storage class
glxgears.c:304: warning: parameter names (without types) in function declaration
glxgears.c:304: warning: data definition has no type or storage class
glxgears.c:305: error: syntax error before numeric constant
glxgears.c:306: warning: data definition has no type or storage class
glxgears.c:308: warning: parameter names (without types) in function declaration
glxgears.c:308: warning: data definition has no type or storage class
glxgears.c:309: error: syntax error before '}' token
Exit 1
I'm very new to the world of command line building with GCC — so if this seams simple please bear with me. =)
You didn't include the include directories for X11 and GL.
Use the -I command
Use the -I command
gcc -I/usr/X11R6/include -lX11 -lGL -lm glxgears.c
glxgears.c:501:2: warning: no newline at end of file
/usr/bin/ld: cannot find -lX11
Exit 1
glxgears.c:501:2: warning: no newline at end of file
/usr/bin/ld: cannot find -lX11
Exit 1
This got me farther, but now I think I have another problem on my hands. I take it I need libm.so.3?
gcc -I/usr/X11R6/include -L/usr/X11R6/lib -lGL -lm glxgears.c
glxgears.c:501:2: warning: no newline at end of file
/usr/bin/ld: warning: libm.so.3, needed by /usr/X11R6/lib/libGL.so, not found (t ry using -rpath or -rpath-link)
gcc -I/usr/X11R6/include -L/usr/X11R6/lib -lGL -lm glxgears.c
glxgears.c:501:2: warning: no newline at end of file
/usr/bin/ld: warning: libm.so.3, needed by /usr/X11R6/lib/libGL.so, not found (t ry using -rpath or -rpath-link)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement