googletest Undefined symbols for architecture x86_64 error

后端 未结 1 2024
抹茶落季
抹茶落季 2020-12-22 04:28

Let GTEST_DIR be the environment variable storing the path to the googletest directory. (I cloned googletest-master from googletest\'s github repo.

相关标签:
1条回答
  • 2020-12-22 04:55

    The problem seems to be due to some linking issues. Have you used the linker flags correctly. For gtest, we need to compile with -lgtest and the linker can link it correctly. Similarly, we need to have the flags for all possible libraries that we are linking against.

    The code

    TEST(dummy_test, test1) { EXPECT_EQ(1,1); }

    int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }

    compiles perfectly for me with command

    clang++ -std=c++11 main.cpp -lgtest

    and I could run the single test without an issue.

    0 讨论(0)
提交回复
热议问题