I cannot get my programs to link...I need help!
I've copied and pasted my code. The main program, the calculateTaxes.cpp function code and my makefile. I am using the makefile to link these two codes together but I get an error when I type 'make' in the command line.
I receive the error code:
assign2c.cpp:(.text+0x169): undefined reference to 'calculateTaxes(float, float, float*, float*, float*)'
collect: ld returned 1 exit status
make: *** [main.exe] error 1
I have no idea what this means!
Code:
/* Name: Arturo
Date: 03/22/13
Purpose: To learn
*/
extern void calculateTaxes(float gross,float deferred, float *ft, float *st, float ........i);
void ovtHrs(float *hrs_wrk, float *ovt_hrs, float hrs, float *gross, float payrate);
#include<stdio.h>
#define BLANKLINES " \n\n"
#define REPORTHEADER "Employee Pay Reg Hrs Gross Fed SSI Net\n"
#define REPORTHEADER1 "Name Rate Ovt Hrs Pay State Defr Pay\n"
#define REPORTFORMAT "%2s %2s %7.2f %16.2f %17.2f %16.2f%15.2f%11.2f\n"
#define REPORTFORMAT1 " %24.2f %34.2f %12.2f\n"
int main(void)
{
char lastname[15], firstname[15];
float payrate=0, hrs_wrk=0, ovt_hrs=0, gross=0, ft=0, st=0, ssi=0, deferred=0, net=0, hrs=0;
printf("Exxxxxnter the last name of the employee\n");
scanf("%s", lastname);
printf("Enter the first name of the employee\n");
scanf("%s", firstname);
printf("Enter the the pay of the employee\n");
scanf("%f", &payrate);
printf("Enter the amount of hours worked\n");
scanf("%f", &hrs);
printf("Enter the deferred amount\n");
scanf("%f", &deferred);
ovtHrs(&hrs_wrk, &ovt_hrs, hrs, &gross, payrate);
calculateTaxes(gross, deferred, &ft, &st, &ssi);
printf(BLANKLINES);
printf(REPORTHEADER);
printf(REPORTHEADER1);
printf(REPORTFORMAT, lastname, firstname, payrate, hrs_wrk, gross, ft, ssi, net);
printf(REPORTFORMAT1, ovt_hrs,st, deferred);
while(getchar()!= '\n');
getchar;
return 0;
}
void ovtHrs(float *hrs_wrk, float *ovt_hrs, float hrs, float *gross, float payrate)
{
if(hrs<=40)
{
*ovt_hrs=0;
*hrs_wrk=hrs;
*gross=hrs*payrate;
}
else
{
*hrs_wrk=40;
*ovt_hrs=hrs-40;
*gross=payrate*40+(hrs-40)*1.5*payrate;
}
}
Code:
#define FEDTAX 0.15
#define STATE 0.07
#define SSITAX 0.0775
void calculatetaxes(float gross, float deferred, float *ft,
float *st, float ........i);
float calcfed(float gross, float deferred);
float calcstate(float ft);
float calcssitax(float gross, float deferred);
void calculatetaxes(float gross, float deferred, float *ft, float *st, float ........i)
{
*ft=calcfed(gross, deferred);
*st=calcstate(*ft);
........i=calcssitax(gross, deferred);
}
float calcfed(float gross, float deferred)
{
return(gross-deferred)*FEDTAX;
}
float calcstate(float ft)
{
return ft*STATE;
}
float calcssitax(float gross, float deferred)
{
return SSITAX*(gross-deferred);
}
Code:
main.exe: assign2c.cpp taxes.o
g++ assign2c.cpp taxes.o -o main.exe
taxes.o: taxes.cpp
g++ -c taxes.cpp -o taxes.o -c