I'm using mingw-w64 (gcc 7.3.0) and when I compile any C++ program using the following command:
g++ file.cpp -fsanitize=undefined
I get the following error:
...mingw32/bin/ld.exe: cannot find -lubsan
I'm able to successfully compile and run my programs if I remove the -fsanitize=undefined
flag, though. After some research I found out that this means the library ubsan (Undefined Behavior Sanitizer) is missing, but I couldn't find anything about the library. How do I fix this?
It is essential that the installation path does not contain any spaces. Therefore, you cannot install MinGW-w64 in Program Files. We recommend to create a folder mingw-w64 on your system drive (e.g., C:\mingw). Install a current version and specify win32 as thread when requested.
Right-click on Computer in the Start Menu and select Properties. Click on "Advanced System Settings", choose the Advanced tab, then click Environment Variables. Under System Variables, scroll down and select Path, then click Edit.
This is well known issue with mingw see for instance this msys github issue. No proper solution known but there are several WAs.
Hope one of this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With