| [linux-help] A c problem[Top] [All Lists][Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
 
 
I'm in chapter 2 of Kernighan and Richey, trying to learn c programming.
I have been using gcc to compile my programs.  I wrote a very simple program 
using math.hand sqrt:
#include <stdio.h>
#include <math.h>
main()                   {
double m, n=8.0;
m=sqrt(n);
printf("%f\n",m);
return 0;
}
and tried to compile it with "gcc -o test-p45 test-p45.c"
It errored with 
 undefined reference to `sqrt'
Same thing when I used kgcc and gcc3.
I compiled it with g++ and it compiled and ran correctly.
Can anyone tell me why gcc seems to not be linking to math.h?
Or should I be using g++ ? (I thought g++ was for C++ and gcc was for plain 
old c.
I am using RH 7.2. and KDE.
bruce
-- This is the linux-help@xxxxxxxxx list.  To unsubscribe,
visit http://www.complete.org/cgi-bin/listargate-aclug.cgi
 
[linux-help] A c problem,
bruce <=
 
 |  |