I've noticed that some projects refer to gtest_main-mdd.lib
and others to gmock_maind.lib
in my Visual Studio 2010 setup and wanted to know what the difference between the two libs is?
What is the difference between gmock_main and gtest_main?
Asked Answered
Projects don't have to use both gtest
and gmock
but one might want to choose using gtest
without gmock
or vice versa. For either case you need a way to introduce the main function, hence you have 2 libs for introducing it.
Anyway, if you are using both then it's better to use gmock_maind.lib
since it has an initialization for the mock framework and for the test framework as well. While gtest_main-mdd.lib
initializes only the test part. Look at the gmock_main.cc and gtest_main.cc
So does that mean that
gmock_maind.lib
assumes you're using it along-side gtest
? If not and you do link against both how can you have two main
functions? Is it done in the linker via weak symbols or what? –
Verbena @nonsensickle, both these libs are just for the initialization. You may not use them at all, you can create your own main and add the required initialization yourself. But once you used either of the libs you have the main function from that lib. It is only one
main
function in each lib so you can't use both libs simultaneously but only one at a time. Gmock's one knows about gtest
and calls init functions for it where Gtest's one doesn't know anything about gmock
and hence doesn't initialize it. –
Goatherd © 2022 - 2024 — McMap. All rights reserved.
gmock_maind.lib
a superset ofgtest_main-mdd.lib
's functionality? – Verbena