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.
Platform | Linker Error Message |
---|---|
Microsoft® Visual Studio® | Message contains error |
MinGW® | Message includes this phrase regarding a construct: |
macOS Xcode | Message includes this phrase: |
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.