I know this isn't the best place to ask this. But, as a complete newbie on
the subject I'm afraid linux-c-programming is for experienced programmers
and I'm not yet up to the standards of that list. Anyway I'll ask the
question and igf you think I'm out of line you can always send me of to a
more appropriate mailinglist.
I've been reading the Beowulf-HOWTO. It contains a listing of a C-program.
I'm interested in the results of the program on my machine. So, I typed in
the code:
----8<---- test.c -----8<----
/*Example from Beowulf-HOWTO */
#include <stdio.h>
#include <math.h>
int main(int argc, char** argv)
{
long number1, number2, counter;
double result;
if (argc < 3)
{
printf("usage: %s number1 number2\n",argv[0]);
exit(1);
}
else
{
number1 = atol(argv[1]);
number2 = atol(argv[2]);
result = 0.0;
}
for (counter = number1; counter <= number2; counter++)
{
result = result + sqrt((double)counter);
}
printf("%lf\n",result);
return 0;
}
---->8----
However when I try to compile this I get something unexpected (an error):
mhe@bilbo:/mnt/pcm > gcc -Wall test.c
test.c: In function `main':
test.c:18: warning: implicit declaration of function `atol'
test.c:28: warning: use of `l' length character with `f' type character
/tmp/cca002611.o: In function `main':
/tmp/cca002611.o(.text+0x9a): undefined reference to `sqrt'
Who can explain what all this means and how I can solve it? I checked and I
saw that I have math.h installed.
--
Maurice Hendrix
snailmail: Fuji Photo Film BV Standard disclaimers apply
Dept. P1LPI
attn. M. Hendrix
PO Box 90156
5000 LJ Tilburg
phone: +31 13-579 1370 or fax: +31 13-579 1385
- We are Linux. You *will* be assimilated. Resistance is futile.