Polyspace Test xUnit tests fails to compile: fatal error: gtest/gtest.h
Show older comments
What parameter controls the C++ include file search path for my gtest test file?
Creating the project file with the python interface, I used (full python program listing attached):
buildConf.ExternalTestsBuildOptions.IncludePaths.add("/nix/store/pqyrsjax8n0wb4dxap66pf6ix6qdz34a-gtest-1.12.1-dev/include/")
This command attempts to build and run the test (mkproj.py attached):
python mkproj.py
That path does not seem to be included into the command line that compiles my test program:
### Building Polyspace Test xUnit tests
### Building for host
### Building 'testbin_sil'
### Using toolchain: GNU gcc/g++ | gmake (64-bit Linux)
...
g++ -c -fwrapv -fPIC -O0 -DPSTEST_BUILD -DPST_USER_CONFIG_FILE -DPST_MAX_NB_PARAMS=31 -I/home/dgeorge/ws/fsw_drivers/cadence_spi -I/home/dgeorge/ws/fsw_drivers/cadence_spi/include -I/nix/store/33r3mf9k7h9f81pybwbhkqzbf9cycg3s-polyspace-installation-R2024a/extern/include -I/nix/store/33r3mf9k7h9f81pybwbhkqzbf9cycg3s-polyspace-installation-R2024a/toolbox/polyspace/pstest/services/driver/host/c -I/nix/store/33r3mf9k7h9f81pybwbhkqzbf9cycg3s-polyspace-installation-R2024a/polyspace/pstest/pstunit/include -I/nix/store/33r3mf9k7h9f81pybwbhkqzbf9cycg3s-polyspace-installation-R2024a/polyspace/pstest/pstunit/src -o "pstunit.o" "/nix/store/33r3mf9k7h9f81pybwbhkqzbf9cycg3s-polyspace-installation-R2024a/polyspace/pstest/pstunit/src/pstunit.cpp"
/home/dgeorge/ws/fsw_drivers/cadence_spi/test_cadence_spi.cpp:6:10: fatal error: gtest/gtest.h: No such file or directory
6 | #include <gtest/gtest.h>
| ^~~~~~~~~~~~~~
Project file snippet (project file attached):
"ExternalTestsOptions": {
"content": {
"IncludePaths": {
"content": {
"IncludePaths": [
{
"content": {
"Path": {
"content": {
"Value": "/nix/store/pqyrsjax8n0wb4dxap66pf6ix6qdz34a-gtest-1.12.1-dev/include"
Directory contents:
$ ls /nix/store/pqyrsjax8n0wb4dxap66pf6ix6qdz34a-gtest-1.12.1-dev/include/gtest
gtest-assertion-result.h gtest-matchers.h gtest-param-test.h gtest-spi.h gtest-typed-test.h gtest_pred_impl.h internal
gtest-death-test.h gtest-message.h gtest-printers.h gtest-test-part.h gtest.h gtest_prod.h
1 Comment
Dan George
on 14 Apr 2024
Answers (1)
David Jaffry
on 12 Nov 2025
1 vote
Hello,
The main issue was actually adding the GTest test under "Polyspace xUnit Test" instead of "External Test Files".
The ExternalTestsBuildOptions setting is specifically intended to support external xUnit test frameworks—such as GTest—in addition to the Polyspace xUnit Test Framework. This allows you to integrate and run tests from other frameworks within the Polyspace environment. You can find more details in the documentation here:
Let me know if you need further clarification!
Categories
Find more on Workflow Automation Using Python API in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!