Syombua Muthoka Syombua Muthoka - 1 year ago 111
C Question

Drawing a 3D cube in C programming

I am currently practicing how to draw a 3D cube in C but during my compilation i am getting this errors.

/tmp/ccAuvH6Y.o: In function `DrawCube':
cube3D.c:(.text+0x1e4): undefined reference to `XGetWindowAttributes'
cube3D.c:(.text+0x203): undefined reference to `glViewport'
cube3D.c:(.text+0x223): undefined reference to `glClearColor'
cube3D.c:(.text+0x22d): undefined reference to `glClear'
cube3D.c:(.text+0x245): undefined reference to `glColor3f'
cube3D.c:(.text+0x24a): undefined reference to `glPushMatrix'
cube3D.c:(.text+0x26c): undefined reference to `glRotatef'
cube3D.c:(.text+0x276): undefined reference to `glEnableClientState'
cube3D.c:(.text+0x280): undefined reference to `glEnableClientState'
cube3D.c:(.text+0x29b): undefined reference to `glColorPointer'
cube3D.c:(.text+0x2b9): undefined reference to `glVertexPointer'
cube3D.c:(.text+0x2d4): undefined reference to `glDrawElements'
cube3D.c:(.text+0x2d9): undefined reference to `glPopMatrix'
cube3D.c:(.text+0x2f2): undefined reference to `glXSwapBuffers'
/tmp/ccAuvH6Y.o: In function `main':
cube3D.c:(.text+0x385): undefined reference to `XOpenDisplay'
cube3D.c:(.text+0x441): undefined reference to `glXChooseVisual'
cube3D.c:(.text+0x4c9): undefined reference to `XCreateColormap'
cube3D.c:(.text+0x548): undefined reference to `XCreateWindow'
cube3D.c:(.text+0x568): undefined reference to `XMapWindow'
collect2: error: ld returned 1 exit status


My Code is as follows.

Answer Source

You have not linked the libraries.

-lgl (or similar)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download