I've been trying to set up a CPPUnitTest to test a C++ project. I've came across an error where I've got two rotating errors depending on how I try to solve my problem.
I've got two projects in a solution in Visual Studio. One is for testing, one is for the project itself. I'm having these errors whilst trying to reference the project in the testing project.
If I do this, I get a LNK2019 (unresolved external symbol) error any time I try to construct an object or call a function:
#pragma once
#ifndef REFERENCE_H
#define REFERENCE_H
#include "../Stuff/Thing.h"
#include "../Stuff/OtherThing.h"
#endif
However, if I do this, I get a LNK2005 (test2.obj: blahblahlblah is already defined in test1.obj) error since two of the tests reference it:
#pragma once
#ifndef REFERENCE_H
#define REFERENCE_H
#include "../Stuff/Thing.cpp"
#include "../Stuff/OtherThing.cpp"
#endif
Deleting one of the tests fixes the problem with the latter (.cpp) but obviously that's not very good.
I think I may have missed a step somewhere along the way but I'm not sure what it is. I did add the "project" project as a dependency to the test.
Does anyone have the solution to this?