15
votes

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?