Why does Polyspace Code Prover R2024b fail compilation before analysis begins when using an external C++ library?

I am using Polyspace Code Prover R2024b to analyze C++ code that includes an external library named "exampleLib".
The analysis fails during the compilation phase before verification begins. The log shows errors similar to:
error: namespace "exampleLib::core" has no member "SomeType"
Failed compilation.
Error limit reached.
The external library headers are present, but Polyspace Code Prover still reports missing namespace members from the library.
Why does Polyspace Code Prover R2024b fail compilation before analysis begins when using this external C++ library, and how can I check the root cause?

 채택된 답변

To troubleshoot this issue in Polyspace Code Prover R2024b, inspect the generated Polyspace options file and review the "-I" include path entries used for the external library.
One possible cause is that the Polyspace options file includes "-I" paths for more than one version or copy of the same external library. For example, the options file might include paths similar to:
-I project/ci/external/exampleLib/versionA/exampleLib
-I project/external/exampleLib
If both locations contain headers with the same names but different contents, Polyspace Code Prover may compile against an incompatible set of headers. This can lead to missing namespace member errors even when the expected header files are present somewhere in the project.
Another possible cause is a namespace mismatch inside one version of the external library headers. For example, a header might define "namespace exampleLib" and then define "namespace exampleLib::core" inside it. This can place declarations under "exampleLib::exampleLib::core" instead of the expected "exampleLib::core". Other source files or headers that refer to "exampleLib::core" can then fail during compilation.
To check whether either issue is the root cause:
  1. Open the generated Polyspace options file.
  2. Search for "-I" entries that point to the external library.
  3. Check whether multiple "-I" entries refer to different versions or copies of the same library.
  4. Compare headers with the same names across those library locations.
  5. Inspect the affected headers for namespace declarations that could define symbols under a nested namespace such as "exampleLib::exampleLib::core".
  6. Update the Polyspace analysis configuration so the options file includes only the intended version of the external library.
  7. Run the Polyspace analysis again.
If duplicate incompatible library versions or namespace mismatches are present, using one consistent version of the external library throughout the Polyspace analysis should resolve the compilation failure.

추가 답변 (0개)

제품

릴리스

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by