Compiling wiht gcc

I have Redhat 7.1 linux. When I tried to compile the double.c from OpenGL Programming Guide(red book) with gcc, it always gave me an error message such as "…libGL.so undefined reference to ‘pow’. The command I used was gcc -L/usr/X11R6/lib -lGL -lGLU -lglut double.c. The double.c does not invoke ‘pow’ by itself. After a while, I used g++ to compile with same libs, and it worked fine. Did anybody have same problem with gcc?

Thanks.

wz

Originally posted by wz:
[b]I have Redhat 7.1 linux. When I tried to compile the double.c from OpenGL Programming Guide(red book) with gcc, it always gave me an error message such as "…libGL.so undefined reference to ‘pow’. The command I used was gcc -L/usr/X11R6/lib -lGL -lGLU -lglut double.c. The double.c does not invoke ‘pow’ by itself. After a while, I used g++ to compile with same libs, and it worked fine. Did anybody have same problem with gcc?

pow is in the math library. Use -lm also.

Jamie

Thanks.

wz[/b]

Hi !

When you use g++ instead of gcc to compile, you get the c++ standard library included when ld is run (even though you don’t see it), and this one need’s the math library, so you also get a -lm behind your back, that’s why it works with g++, if you use gcc, just add the -lm as mentioned above.

Mikael

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.