Main Content

Resolve Build Error: Unresolved External Symbols

Issue

When publishing a MATLAB® interface to a C++ library, MATLAB compiles and builds C/C++ code. If the library files or supporting source files contain unresolved external symbols, a linker error occurs when you publish the interface.

The linker error message text depends on your platform and can reference a construct, such as a function, method, or variable.

PlatformLinker Error Message

Microsoft® Visual Studio®

Message contains error LNK2019 and might include this phrase: unresolved external symbol.

MinGW®
Linux® gcc

Message includes this phrase regarding a construct: undefined reference.

macOS Xcode

Message includes this phrase: undefined symbols.

Possible Solutions

The unresolved external symbols issue can have several possible causes and solutions, including:

  • Compiler mismatch — Verify that the compiled library file you chose is compiled with the compiler you specified in the Generate C++ Interface C++ compiler parameter.

  • Incomplete files — Verify that the supplied library files or supporting source files are complete and contain full construct definitions.

  • Unrelated files — Verify that the supplied library files or supporting source files belong to the library.

For more possible causes and solutions, see this Microsoft article: Linker Tools Error LNK2019.