Google Test and supporting multiple main methods in native CPP project

We are attempting to use Gradle 2.4 (or 2.5 rc1) for a new CPP application with Google Test as our unit-test frame work. We are getting the error:
multiple definition of `main’
which is due to us having 2 main’s: one to drive google tests, and one for the main application. Using the samples/native/googletestsamples/native/googletest project, can you show me (if it is possible) the correct way to construct the build.gradle file if the example operators library was instead a NativeExecutableSpec which also had a main method like: samples/native-binaries/google-test/src/operators/cpp/main.cpp, where main.cpp is something like:

int main(int argc, char ** argv) {
std::cout << “Hello World” << std::endl;
return 0;

Thank you, -Adam

Thanks for the report. At this stage Gradle’s integration with GoogleTest (or CUnit) only works correctly with components that do not define a separate main method. I’ve raised GRADLE-3316 to track this issue.

As a workaround, you could use a macro with #ifdef to tell Gradle to ignore the main method from the executable when compiling the google test sources.