I've wasted many hours to resolve this problem, but without success. At first, my configuration: Ubuntu 16.04.1, qmake 3.0, cmake 3.5.1, shared gtest and gmock libraries, version 1.8.0. I use Qt Creator, and this is a little example of minimal program that lead to the crush.
main.cpp:
#include <iostream>
#include <gtest/gtest.h>
#include <gmock/gmock.h>
using namespace std;
class A {
void print() {
std::cout << "PRINT" << std::endl;
}
};
class B: public A {
MOCK_METHOD0(print, void());
};
TEST(MOCK, TEST) {
B b;
}
int main(int argc, char *argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
google_test.pro:
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
LIBS += -lgtest -lgmock
Tests are OK, but at the end of program I get this error:
* Error in `/home/aminought/QtProjects/build-google_test-Desktop_Qt_5_7_0_GCC_64bit-Debug/google_test': double free or corruption (!prev): 0x0000000001a51270 *
How to fix this error? Very annoying.
This problem occurs only with google test compiled as shared libraries. I don't know why, but simple replacement of shared libraries to static solves the problem.