Apple Mach-O Linker Error

I am new to c++ and I am programming in Xcode. I believe my problem lies in my #include statements, but I'm not sure. Most of my program is a skeleton, so it doesn't really do anything yet.

Also, I know this probably isn't good practice, but I removed a bunch of stuff that was most likely irrelevant. Additionally, this is my homework, but I'm not asking for help with any of the important stuff. ;)

The error I'm getting:

1
2
3
4
5
duplicate symbol __ZN5Loans13printFineListEv in:
    /Users/user/Library/Developer/Xcode/DerivedData/HW5_2-cbqokpjasujyveeseanzjyhpuseo/Build/Intermediates/HW5_2.build/Debug/HW5_2.build/Objects-normal/x86_64/classes.o
    /Users/user/Library/Developer/Xcode/DerivedData/HW5_2-cbqokpjasujyveeseanzjyhpuseo/Build/Intermediates/HW5_2.build/Debug/HW5_2.build/Objects-normal/x86_64/main.o
ld: 50 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)


In classes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <string>

using namespace std;

class Patron{
    
private:
    int patronID;
    //More variables
    
public:
    Patron();
    //More functions for the class
};


In classes.cpp
1
2
3
4
5
6
7
8
9
10
#include "classes.h"

/*---------- Patron class ----------*/

Patron::Patron(){
    //Nothing here
}

//All the other skeleton functions for the class(es)


In main.cpp
1
2
3
4
5
6
7
8
#include "classes.cpp"

int main() {    
    
    cout << "Welcome to the Library System" << endl << endl;
    
    //Menu here
}
Last edited on
Topic archived. No new replies allowed.