Using g++ in Linux, I have 2 .C files and a .h file:
Code://Fibonacci.h
#ifndef FIBONACCI_H
#define FIBONACCI_H
unsigned int Fibonacci (unsigned int);
#endif /* FIBONACCI_H */
Code://Fibonacci.C
#include "Fibonacci.h"
unsigned int Fibonacci (unsigned int n)
{
if ( (n == 0) || (n == 1) )
return 1;
else
return (Fibonacci(n-1) + Fibonacci(n-2));
}
Code://main.C
#include <iostream>
using namespace std;
#include "Fibonacci.h"
int main() {
unsigned int n;
for (n=1; n<10; n++) {
cout << Fibonacci(n) << " ";
}
cout << endl;
return 1;
}
I've also got a Makefile, so I run
and get the following error message:Code:make -f main
I've tried numerous things to correct this, but to no avail.Code:undefined reference to 'Fibonacci(unsigned)'
Does anyone know what I'm doing wrong?
Any help would be really appreciated.
Thanks