I'm trying to build a solution with 2 projects and get these error messages:
ColliderTest.obj : error LNK2028: undefined token (0A000080) "public: __thiscall Rect::Rect(int)" (??0Rect@@$$FQAE@XZ) referenced in function "void __cdecl myFunction(void)" (?myFunction@@$$FYAXXZ)
ColliderTest.obj : error LNK2019: unresolved external symbol "public: __thiscall Rect::Rect(int)" (??0Rect@@$$FQAE@XZ) referenced in function "void __cdecl myFunction(void)" (?myFunction@@$$FYAXXZ)
The code:
Collider.h
#pragma once
class Rect{
int x;
int y;
unsigned int w;
unsigned int h;
public:
Rect(int x);
};
Collider.cpp
#include "Collider.h"
Rect::Rect(int x){
this->x = x;
}
ColliderTest.cpp
#include "../app/Collider.h"
void myFunction();
void myFunction(){
Rect rect(4);
}
Also, each project has a main.cpp file with an empty main() function, to avoid the complains of the compiller about the entry point.
Both projects have a main function?
That means you are building two executable. Executables typically do not export functions.
You need one executable and one class library (dll).
BTW: If you have an empty main function, how will you know if your program ran?