Linker error?

I have three different files for the test class I am trying to use.. The first one will be the main prog7.cpp, the second one with be the implementation, gameclass1.cpp and the third the header, gameclass1.hpp

I am getting a weird linker error and have no idea why. All I'm trying to do is a simple output before I start the actual program and it's not working.

Main:
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include "gameclass1.hpp"

using namespace std;

int main(){
    
    Test object;
    
    return 0;
}


Implementation:
1
2
3
4
5
6
7
8
9
10
#include "gameclass1.hpp"
#include <iostream>

using namespace std;

Test::Test(){
    
    cout << "Testing 1..2..3" << endl;
    
}


Header:
1
2
3
4
5
6
7
8
9
10
#ifndef gameclass1_hpp
#define gameclass1_hpp

class Test
{
public:
    Test();
};

#endif /* gameclass1_hpp */ 



The linker error is as follows:

Undefined symbols for architecture x86_64:
"Test::Test()", referenced from:
_main in prog7-5c1bd1.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Are you sure you're actually compiling both .cpp files, and linking together both the object files created from those .cpp files?
Topic archived. No new replies allowed.