On Ubuntu Linux, I have been following the gtest
instructions given here to install gtest
with manually copying the header files and libraries to /usr/include
and /usr/lib
, respectively.
I then tried to compile the following code (test1.cpp
)
#include <gtest/gtest.h>
TEST(MathTest, TwoPlusTwoEqualsFour) {
EXPECT_EQ(2 + 2, 4);
}
int main(int argc, char **argv) {
::testing::InitGoogleTest( &argc, argv );
return RUN_ALL_TESTS();
}
with the following command
g++ -lgtest -lgtest_main -lpthread test1.cpp
just to see yet another unhelpful error message:
/usr/bin/ld: /tmp/ccQlmghI.o: undefined reference to symbol '_ZN7testing8internal9EqFailureEPKcS2_RKSsS4_b'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libgtest.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
How can I fix this? Or is there another unittest framework which can be used in a SIMPLE way, with a working example?
The same question has been asked here, but without an answer.