I've started out learning how to use Catch2 for testing my C++ code and am trying to set up a simple test.
My folder structure consists of three files all in the same folder:
catch.cpp //this is the catch_amalgamated.cpp file from GitHub
catch.hpp //this is the catch_amalgamated.hpp file from GitHub
test.cpp //this is my test file
All I have written in test.cpp
is:
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
When I try to compile test.cpp
I get the following error which I think indicates that there is no main()
function found(?):
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x2e): undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status
When I add a nominal main()
function, the file compiles successfully, but as I understand it #define CATCH_CONFIG_MAIN
is supposed to create the main()
function for you so something clearly isn't working.
Can anyone shed any light on this?