I use GoogleTest for testing my C++ projects, and after finding that precompiled libraries were no longer distributed in the Ubuntu package, I found the following on the project website:

If you compile Google Test and your test code using different compiler flags, they may see different definitions of the same class/function/variable (e.g. due to the use of #if in Google Test). Therefore, for your sanity, we recommend to avoid installing pre-compiled Google Test libraries. Instead, each project should compile Google Test itself such that it can be sure that the same flags are used for both Google Test and the tests.

What I take from this is that it's a bad idea to compile GoogleTest separately from the project being testing. What I don't understand is whether this is just a GoogleTest thing, or if this is a general thing for linking libraries.

Question

Is there any situation in which it is unsafe to link to precompiled third-party libraries, compiler flags or otherwise, and if not, what's so special about GoogleTest?

Edit
Report