I want to build a small example project using cpputest under MSVS2019. For this I build a solution with an empty project (will contain my source files later), the included cpputest-repository and my utest-project where I want to write the tests for the first project.
When I build, I get a lot of unresolved symbol errors from the linker although visual studio "knows" (when I click on them, I can open the connected .cpp-files, look at their defs and so on)... first one is:
Error LNK2019 unresolved external symbol "public: static int __cdecl CommandLineTestRunner::RunAllTests(int,char * *)" (?RunAllTests@CommandLineTestRunner@@SAHHPAPAD@Z) referenced in function _main UnitTest C:\...\UnitTest\AllTests.obj 1
This is what I have tried:
- I first downloaded the 3.8.-zip at https://cpputest.github.io/ and found a word file in /doc that explained how to set up the msvs-project (it was relevant for vs2010 but I figured it cant be that far off what I want to do in vs2019).
- When I tried to build this solution I couldn't build this solution, some files were not to be found and I figured I have the same problem as described here: https://github.com/cpputest/cpputest/issues/1046 - so far so good
- I cleaned the compiler and linker that is used for the unittest-project from all the unnecessary legacy configuration and now I am only using the compiler configuration:
AdditionalIncludeDirectories C:\Projects\cpputest\include;
and linker configuration:
additional library directory "C:\Projects\cpputest\lib"
This results in the cl text:
/JMC /ifcOutput "Debug" /GS /analyze- /W1 /Zc:wchar_t /I"C:\Projects\cpputest\include" /ZI /Gm- /Od /Fd"Debug\vc142.pdb" /FI"C:\Projects\cpputest/include/CppUTest/MemoryLeakDetectorNewMacros.h" /FI"C:\Projects\cpputest/include/CppUTest/MemoryLeakDetectorMallocMacros.h" /Zc:inline /fp:precise /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /Oy- /MDd /FC /Fa"Debug" /EHsc /nologo /Fo"Debug" /Fp"Debug\UnitTest.pch" /diagnostics:column
and the linker text
/OUT:"C:\Projects\dummyfirmware_cpputest\dummyFirmware_CppUTest_Solution\Debug\UnitTest.exe" /MANIFEST /NXCOMPAT /PDB:"C:\Projects\dummyfirmware_cpputest\dummyFirmware_CppUTest_Solution\Debug\UnitTest.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG:FULL /MACHINE:X86 /INCREMENTAL /PGD:"C:\Projects\dummyfirmware_cpputest\dummyFirmware_CppUTest_Solution\Debug\UnitTest.pgd" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Debug\UnitTest.exe.intermediate.manifest" /LTCGOUT:"Debug\UnitTest.iobj" /ERRORREPORT:PROMPT /ILK:"Debug\UnitTest.ilk" /NOLOGO /LIBPATH:"C:\Projects\cpputest\lib" /TLBID:1
My code:
//AllTestsCpp
#include "CppUTest/TestHarness.h"
#include "CppUTest/CommandLineTestRunner.h"
IMPORT_TEST_GROUP(FirstTestGroup);
int main(int ac, char** av)
{
return CommandLineTestRunner::RunAllTests(ac, av);
}
#include "CppUTest/CommandLineTestRunner.h"
TEST_GROUP(FirstTestGroup)
{
};
TEST(FirstTestGroup, FirstTest)
{
FAIL("Fail me!");
}
Anyone has an idea where I went wrong?