I am taking an Arduino course on Coursera and was required to write a program to list the first 6 Fibonocci number. Rather a trivial assignment so I decided to go a different route and calculate the numbers using the Golden Mean. However I cannot get the program to build using the Geany IDE on Linux Mint. The code compiles without error but won't build. It compiles without error on the Arduino also. But if I can't build it I can't submit it or test it.
#include <stdio.h>
#include <math.h>
double GoldenMeanA;
double GoldenMeanB;
int i;
double x;
int main()
{
printf ("the Fibonocci numbers are ");
for ( i = 1; i < 7 ; i++ )
{ GoldenMeanA = pow(1.61, i);
GoldenMeanB = pow(-.61, i);
x = (GoldenMeanA) - (GoldenMeanB) / (sqrt (5));
printf("%f", x);
}
return 0;
}
I am a complete novice at C programming. These are the errors from Geany:
gcc -Wall -o "fibass2" "fibass2.c" (in directory: /home/q/Desktop/Learn C)
/tmp/ccXlfYCE.o: In function `main':
fibass2.c:(.text+0x45): undefined reference to `pow'
fibass2.c:(.text+0x95): undefined reference to `pow'
collect2: error: ld returned 1 exit status
Compilation failed.
I don't know what any of that means but I thought math.h
was a built-in library. Shouldn't Geany know what in the heck "pow" is?