jeudi 30 juillet 2015

C++ Unit Test Native C++

First, a little background:

At work, I've inherited a large C++ program (a language I haven't used extensively in 12 years). To help myself better understand the application and how it fits together, I thought, "I love TDD, why not write some unit tests!". I've since spent two days getting a simple unit test to compile. I'm at the point where it gets to the linker, but I get the following error:

CIniReader* reader = new CIniReader("");


Error   3   error LNK2019: unresolved external symbol "public: __thiscall CIniReader::CIniReader(char *)" (??0CIniReader@@$$FQAE@PAD@Z) referenced in function "public: void __clrcall ApogeeTests::UnitTest1::TestMethod1(void)" (?TestMethod1@UnitTest1@ApogeeTests@@$$FQ$AAMXXZ) C:\Users\champad\Documents\Applications\Leading Hedge\src\Apogee.Tests\UnitTest1.obj    Apogee.Tests

Now, I can resolve this buy setting the project that this lives in to a static library, rather than a DLL project (Properties -> Configuration Properties -> General -> Configuration Type).

My question is this: MUST I do this? It seems there has to be a way for the linker to identify the functions it needs at compile time without having to constantly switch all 24 projects to lib when I want to unit test, and back when I need to deploy it.

Any thoughts?

Aucun commentaire:

Enregistrer un commentaire