Fix Undefined Symbol Errors in Polyspace Platform User Interface
Issue
If you build a Polyspace® Platform project containing undefined functions and variables, you see an error such as the following on the Logs pane:
Project has following undefined symbols:
undefined_function_namePossible Solutions
The symbols indicated in the error message might be actually undefined. In this case, add a definition for the symbol to your code. However, if your code builds without errors outside the Polyspace Platform user interface, the error usually indicates an issue with your project setup.
You can work around the error by adding stubs for the undefined symbols or by disabling the check for undefined symbols.
Add Stub for Undefined Symbol
If the symbol is not relevant for testing, you can add a stub to stand in for the symbol. For instance, if the function under test has an undefined callee that is supposed to print some information and the printed information is not relevant for your test, you can stub the callee with no effect on the test results.
For more information, see Test Functions with Undefined Callees in Polyspace Platform User Interface.
Disable Check for Undefined Symbols
Sometimes, the definition of an undefined symbol is in a static or dynamic library that is linked at build time. In this case, you can completely disable the check for undefined symbols or allow certain symbols to be undefined in your project configuration. At build time, your linker can find the definitions in the linked libraries and complete the project build.
To apply this workaround:
In your project configuration, on the Build tab, select Target & Compiler.
Clear Check undefined symbols. Alternatively, instead of completely disabling the check for undefined symbols, you can enter the symbol name for the option External symbols.
Specify your libraries using the options Library paths and Libraries.
For instance, consider the file sourceFile.c containing the
following code:
#include <stdio.h>
#include "arithmetic.h"
int get_result () {
int result = multiply(add(3, 4), 6);
return result;
}add(int, int) and
multiply(int, int) are defined in a static library file
arithmetic.a that you link at build time. For instance, you might be
invoking a GCC compiler as
follows:gcc sourceFile.c -l:arithmetic.a
sourceFile.c to a Polyspace Platform project and build the project, you see an error indicating that the
functions add and multiply are undefined. To work
around the error, in your project configuration:
Disable the check for undefined symbols or specify
addandmultiplyas external symbols.Specify the file
arithmetic.aas an external library to be used during linking.
See Also
Check undefined symbols | External symbols