Reputation: 3917
Am getting this error for my code:
Undefined symbols for architecture x86_64:
"_spendDollars", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Have checked the code, but can't find the error. Here it is:
#import <Foundation/Foundation.h>
typedef struct {
float exchangeRate;
double budget;
//double euroTransaction;
double exchangeTransaction;
} budget;
//budget vacationBudget;
budget vacationBudgetEurope;
budget vacationBudgetEngland;
//void spendDollars (double dollars);
//void chargeEuros (double euros);
void spendDollars(budget* theBudget, double dollars);
void chargeForeignCurrency(budget* theBudget, double foreignCurrency);
int main(int argc, const char * argv[])
{
//budget vacationBudget;
//vacationBudget.exchangeRate = 1.2500;
vacationBudgetEurope.budget = 1000;
//vacationBudget.budget = 1000.00;
vacationBudgetEurope.budget = 1000.00;
//double numberDollars = 100;
double numberDollarsInEuroland = 100;
double numberEuros = 100;
vacationBudgetEngland.exchangeRate = 1.5000;
vacationBudgetEngland.budget = 2000.00;
double numberDollarsInPoundland = 100;
double numberPounds = 100;
//vacationBudget.budget -= 100.00;
//spendDollars(numberDollars);
spendDollars(&vacationBudgetEurope, numberDollarsInEuroland);
//NSLog(@"Converting %.2f US dollars into euros leaves $%.2f dollars", numberDollars, vacationBudget.budget);
NSLog(@"Converting %.2f US dollars into euros leaves $%.2f", numberDollarsInEuroland, vacationBudgetEurope.budget);
//chargeEuros(numberEuros);
chargeForeignCurrency(&vacationBudgetEurope, numberEuros);
//NSLog(@"Charging %.2f euros leaves $%.2f", numberEuros, vacationBudget.budget);
NSLog(@"Charging %.2f euros leaves $%.2f", numberEuros, vacationBudgetEurope.budget);
spendDollars(&vacationBudgetEngland, numberDollarsInPoundland);
NSLog(@"Converting %.2f US dollars into pounds leaves $%.2f", numberDollarsInPoundland, vacationBudgetEngland.budget);
chargeForeignCurrency(&vacationBudgetEngland, numberPounds);
NSLog(@"Charging %.2f pounds leaves $%.2f", numberPounds, vacationBudgetEngland.budget);
return 0;
}
//void spendDollars (double dollars) {
// vacationBudget.budget -= dollars;
//}
void chargeForeignCurrency (budget* theBudget, double foreignCurrency) {
theBudget -> exchangeTransaction = foreignCurrency*theBudget -> exchangeRate;
theBudget ->budget -= theBudget -> exchangeTransaction;
}
Upvotes: 0
Views: 430
Reputation: 225132
That error message is telling you exactly what the problem is. You don't have a function called spendDollars()
in your program. Well, you do, but it's commented out. The commented out function doesn't match the signature you're using though, so it looks like you have some code to write.
Upvotes: 3