Googletest: Linker fails for UnorderedElementsAreArray but fine with ElementsAreArray

Created on 22 Sep 2017  路  1Comment  路  Source: google/googletest

I'm getting this linker error when using
ASSERT_THAT(std::vector<int>({1, 2, 3}), ::testing::UnorderedElementsAreArray({1, 2, 3}));

Linker error:
/usr/local/include/gmock/gmock-matchers.h:3369: undefined reference to 'testing::internal::UnorderedElementsAreMatcherImplBase::DescribeToImpl(std::ostream*) const'

But it compiles and links fine when
ASSERT_THAT(std::vector<int>({1, 2, 3}), ::testing::ElementsAreArray({1, 2, 3}));

I freshly compiled it using the latest master at bfc0ffc8a698072c794ae7299db9cb6866f4c0bc using with GCC 7.1

Most helpful comment

Turns out, while ::testing::ElementsAreArray does not require libgmock library, ::testing::UnorderedElementsAreArray does, which I foolishly forgotten to link.

>All comments

Turns out, while ::testing::ElementsAreArray does not require libgmock library, ::testing::UnorderedElementsAreArray does, which I foolishly forgotten to link.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

markfrazzetto picture markfrazzetto  路  3Comments

cyberdecker picture cyberdecker  路  3Comments

tschijnmo picture tschijnmo  路  4Comments

ElectricRCAircraftGuy picture ElectricRCAircraftGuy  路  4Comments

ebioman picture ebioman  路  3Comments