我已将Catch2
作为子模块添加到我的项目中,并Catch2/include/catch.hpp
使用以下代码包含标题:
测试main.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);
}
但我得到一个链接器错误:
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
我究竟做错了什么?我认为 Catch2 应该在其标题中是自包含的,并且不需要任何.cpp
文件来提供其符号?