docs: clarify gtest and gtest_main linking requirements

Signed-off-by: Aryan Sachin <aryansachinixd@gmail.com>
This commit is contained in:
Aryan Sachin 2026-10-26 17:23:01 +05:30
parent cd8e73f067
commit d3ae5872a1

View File

@ -381,8 +381,8 @@ If a fatal failure happens the subsequent steps will be skipped.
## Writing the main() Function
Most users should *not* need to write their own `main` function and instead link
with `gtest_main` (as opposed to with `gtest`), which defines a suitable entry
point. See the end of this section for details. The remainder of this section
with `gtest_main` (which defines a suitable entry point) rather than linking only
with `gtest`. See the end of this section for details. The remainder of this section
should only apply when you need to do something custom before the tests run that
cannot be expressed within the framework of fixtures and test suites.
@ -468,6 +468,12 @@ agree with you completely, and that's why Google Test provides a basic
implementation of main(). If it fits your needs, then just link your test with
the `gtest_main` library and you are good to go.
{: .callout .note}
*Note:* In supported build systems such as CMake and Bazel, linking with
`gtest_main` automatically includes `gtest` transitively. If you are linking
manually (e.g., directly invoking `clang++` or `g++`), you will need to link
both libraries: `-lgtest_main -lgtest`.
{: .callout .note}
NOTE: `ParseGUnitFlags()` is deprecated in favor of `InitGoogleTest()`.