- 1 year ago
Clang++ shipped with Visual Studio 2019: lld-link reports undefined symbol __guard_eh_cont_table
The undefined symbol __guard_eh_cont_table
error can occur when using Clang++ shipped with Visual Studio 2019 on Windows, specifically when linking with the lld-link
linker.
This error typically occurs when using C++ exceptions or when using the /guard:cf
linker option to enable Control Flow Guard (CFG).
Here are a few possible solutions to try:
Update to the latest version of Visual Studio 2019, which includes updates to Clang and lld-link that may resolve the issue.
Disable CFG by removing the
/guard:cf
option from the linker command line.If you need to use CFG, try adding the
/d2guard4
option to the Clang++ compiler command line, which enables a workaround for the issue. This option will generate additional code that resolves the undefined symbol error. For example:bashclang++ /d2guard4 file1.cpp file2.cpp /link /guard:cf
Another workaround is to add the
legacy_stdio_definitions.lib
library to the linker command line. This library provides compatibility with older versions of Visual Studio and may resolve the issue. For example:bashclang++ file1.cpp file2.cpp /link legacy_stdio_definitions.lib
Hopefully, one of these solutions will resolve the undefined symbol __guard_eh_cont_table
error when using Clang++ shipped with Visual Studio 2019 on Windows with lld-link.