问题
I am using CxxTest for unit testing. I followed the docs.
First command I executed was:
cxxtestgen --error-printer -o runner.cpp MyTestSuite1.h
Output of the command is runner.cpp file.
According to the documentation, next command should be:
g++ -o runner -I(location_of_the_cxxTest_headers) runner.cpp
but I am unable to execute it, I am receiving the error about missing entry point. In other words, runner.cpp is missing main.
Same thing happens with the test files included with CxxTest.
I am running Windows 8.1.
My question is marked as a duplicate, but I didn't find solution in the another question. I am not building a GUI application. Question is about CxxTest and how does it even start without a main() function? Where is the entry point?
回答1:
I have found a solution after looking at a python script cxxtestgen.py which is used to generate runner.cpp. There is an if statement at the beginning of a writeMain(output) function which writes main function in an output file:
if not (options.gui or options.runner):
return
At least one of the two options, --runner=CLASS and --gui=CLASS is required when generating output file from test suites. After adding one option everything runs fine.
来源:https://stackoverflow.com/questions/37644452/cxxtest-compiling-missing-main