I've added Catch2
as a submodule to my project and included the Catch2/include/catch.hpp
header using the following code:
testmain.cpp:
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
#include "catch.hpp"
TEST_CASE( "Test test", "[test]" ) {
REQUIRE(true);
}
but I get a linker error:
Undefined symbols for architecture x86_64: "Catch::NameAndTags::NameAndTags(Catch::StringRef const&, Catch::StringRef const&)", referenced from: ___cxx_global_var_init.1 in testmain.cpp.o
What am I doing wrong? I thought Catch2 was supposed to be self-contained in its header and didn't need any .cpp
file to provide its symbols?
Figured it out thanks to a response to one of the Catch2 Github Issues:
horenmar:
The version in
includes/
is the original file the "real" Catch2 header is generated from. The one you're supposed to include is inCatch2/single_include/catch2/catch.hpp
. So make sure your header search paths are set to search there forcatch.hpp
, not inincludes
.