Contenido principal

Troubleshoot Building GoogleTest Tests from Polyspace Platform Projects

R2026b

Issue

You can import GoogleTest tests into a Polyspace® Platform project and build them using a similar workflow as tests authored using the Polyspace Test™ C/C++ xUnit API. Before building your GoogleTest tests, you have to set up your project configuration so that the appropriate GoogleTest libraries can be found during the build. If the project configuration is not correctly set up, you might encounter errors during build. This topic covers some possible resolutions for the GoogleTest build errors.

Possible Solutions

Build Tests and GoogleTest Libraries Using Same Compiler

To be able to build GoogleTest tests, you must specify the GoogleTest libraries using these Polyspace options in your project configuration:

If the libraries were built using a compiler that is different from the compiler in your Polyspace Platform project configuration, the required GoogleTest definitions might not be found during build and you run into linking errors such as:

undefined reference to <symbolName>

For instance, your build might be showing errors because your GoogleTest libraries were built using a Visual Studio® compiler but you are using a MinGW compiler in your Polyspace Platform project. For more information on how to find the compilers used for Polyspace Platform project builds, see Specify C/C++ Compilers for Testing in Polyspace Platform User Interface.

Cross-Compile GoogleTest Libraries for Target Architecture

If you are running GoogleTest tests on a registered embedded target, the GoogleTest libraries specified in your project configuration must be cross-compiled for the target architecture. If the libraries were compiled only for on-host execution, you will encounter linking errors when building tests for the target.

To resolve this issue, rebuild the GoogleTest libraries using the same cross-compiler that is specified in your target registration. Then update the Library paths for external tests option in your project configuration to point to the cross-compiled libraries.

To check if you are building your tests for on-target execution, see your specifications for the option Target board name (Testing).

See Also

| |

Topics