i can’t compile a simple gl-prog

following errors:

zwergi@workstation:~/devel/gl > gcc gltest.c -lGL -lglut -lGLU
gltest.c: In function main': gltest.c:31: warning: passing arg 1 ofglutInit’ makes pointer from integer without a cast
/usr/lib/ undefined reference to XGetExtensionVersion' /usr/lib/ undefined reference toXFreeDeviceList’
/usr/lib/ undefined reference to XQueryDeviceState' /usr/lib/ undefined reference toXListInputDevices’
/usr/lib/ undefined reference to cos' /usr/lib/ undefined reference tosin’
/usr/lib/ undefined reference to XFreeDeviceState' /usr/lib/ undefined reference toXOpenDevice’
/usr/lib/ undefined reference to tan' /usr/lib/ undefined reference toXmuLookupStandardColormap’
/usr/lib/ undefined reference to XSelectExtensionEvent' /usr/lib/ undefined reference tofist_tessellation’
/usr/lib/ undefined reference to `acos’
collect2: ld returned 1 exit status

and when i use g++ instead of gcc i don’t get the undefined references but i don’t become an output?
where is the problem??

I use SuSE Linux 7.2 and have an Elsa Gladiac 2 GTS

Your undefined references are because you need to pass some more libraries to the linker. For the X errors, try passing -lX11. From memory there may be some others as well. On SGI machines here at uni one of my old makefiles has these: -lXmu -lXext -lX11 -lXi but not all of these will exist (I think) on Linux. I’m guessing that -lXext and -lX11 will be on Linux. You also want to pass -lm for the math functions. As for fist_tessellation, I guess that’s in one of your proprietary libraries so you’ll have to link that as well.

The warning at the top is probably due a mistake on your part. I’m guessing your main function looks like this:

int main(int argc, char **argv)
glutInit(argc, argv);

when it should look like this:

int main(int argc, char **argv)
glutInit(&argc, argv);

Hope that helps.

I use the following command:

gcc -Wall -I/usr/X11R6/include/ -o cube -L/usr/X11R6/lib cube.c -lX11 -lXi -lXmu -lglut -lGL -lGLU -lm

where cube.c is my file and cube is my output.
The sin, cos, etc. might be because the math library is not being included (#include<math.h> .
Hope this helps.