jmvbxx
Programmer
- Dec 18, 2008
- 2
I am a brand new coder learning from C++ for Mathematicians. I have three files: gcd.h, gcd.cpp and gcd-tester.cpp
What I'd like to know if how to compile them so that I can run them.
I believe that gcd-tester.cpp needs gcp.cpp in order to compile.
Here is the error I receive:
Any help is very appreciated!
Here is the code for gcd-tester.cpp
What I'd like to know if how to compile them so that I can run them.
I believe that gcd-tester.cpp needs gcp.cpp in order to compile.
Here is the error I receive:
~/coding/cpp/gcd$ g++ gcd-tester.cc -o gcd-tester
/tmp/ccvi6bre.o: In function `main':
gcd-tester.cc.text+0xcc): undefined reference to `gcd(long, long)'
collect2: ld returned 1 exit status
Any help is very appreciated!
Here is the code for gcd-tester.cpp
Code:
#include "gcd.h"
#include <iostream>
using namespace std;
/**
* A program to test the gcd procedure.
*/
int main() {
long a,b;
cout << "Enter the first number --> ";
cin >> a;
cout << "Enter the second number --> ";
cin >> b;
cout << "The gcd of " << a << " and " << b << " is "
<< gcd(a,b) << endl;
return 0;
}