gtest instalado con conan: referencia indefinida a `testing :: internal :: GetBoolAssertionFailureMessage`
yo suelocmake para construir mi proyecto yconan instalarPrueba de Google como dependencia:
conanfile.txt
[requires]
gtest/1.7.0@lasote/stable
[generators]
cmake
[imports]
bin, *.dll -> ./build/bin
lib, *.dylib* -> ./build/bin
CMakeLists.txt
PROJECT(MyTestingExample)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
INCLUDE(conanbuildinfo.cmake)
CONAN_BASIC_SETUP()
ADD_EXECUTABLE(my_test test/my_test.cpp)
TARGET_LINK_LIBRARIES(my_test ${CONAN_LIBS})
prueba / my_test.cpp
#include <gtest/gtest.h>
#include <string>
TEST(MyTest, foobar) {
std::string foo("foobar");
std::string bar("foobar");
ASSERT_STREQ(foo.c_str(), bar.c_str()); // working
EXPECT_FALSE(false); // error
}
Construir
$ conan install --build=missing
$ mkdir build && cd build
$ cmake .. && cmake --build .
Puedo usarASSERT_STREQ
, pero si usoEXPECT_FALSE
Me sale un error inesperado:
my_test.cpp:(.text+0x1e1): undefined reference to `testing::internal::GetBoolAssertionFailureMessage[abi:cxx11](testing::AssertionResult const&, char const*, char const*, char const*)'
collect2: error: ld returned 1 exit status
¿Qué hay de malo en mi configuración?