當我不知道如果我安裝我的GTEST環境中正常。當我做普通TEST
與EXPECT_EQ
的東西,這一切都很好。然而,當我嘗試像TEST_F
這樣的鴿友時,鏈接器會抱怨。GTEST - 未定義符號使用TEST_F
源代碼:
class MyTest : public testing::Test
{
protected:
static const int my_int = 42;
};
TEST_F(MyTest, test)
{
EXPECT_EQ(my_int, 42);
}
這給
Undefined symbols for architecture x86_64:
"MyTest::my_int", referenced from:
MyTest_test_Test::TestBody() in instruction_test.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [tests/tests/run_tests] Error 1
make[2]: *** [tests/tests/CMakeFiles/run_tests.dir/all] Error 2
make[1]: *** [tests/tests/CMakeFiles/run_tests.dir/rule] Error 2
make: *** [run_tests] Error 2
任何想法,爲什麼出現這種情況?
這是C++,它沒有任何與谷歌測試。類聲明中的任何靜態類成員都必須實例化(定義)。 – glagolig