【问题标题】:Cannot find -lubsan on using -fsanitize=undefined (mingw-w64)在使用 -fsanitize=undefined (mingw-w64) 时找不到 -lubsan
【发布时间】:2019-05-30 08:00:40
【问题描述】:

我正在使用 mingw-w64 (gcc 7.3.0),当我使用以下命令编译任何 C++ 程序时:

g++ file.cpp -fsanitize=undefined

我收到以下错误:

...mingw32/bin/ld.exe: 找不到 -lubsan

如果我删除-fsanitize=undefined 标志,我能够成功编译和运行我的程序。经过一番研究,我发现这意味着缺少库 ubsan(未定义的行为消毒剂),但我找不到有关该库的任何信息。我该如何解决这个问题?

【问题讨论】:

    标签: c++ gcc compiler-errors compilation g++


    【解决方案1】:

    这是 mingw see for instance this msys github issue 的众所周知的问题。没有合适的解决方案,但有几个 WA。

    1. 在 WSL 上安装 WSL、ubuntu,您将在其中拥有 ubsan
    2. 在 Windows 下从源代码构建 GCC,启用 sanitizers 构建。他们是 present in GCC sources 他们只是不在 mingw。
    3. 仅使用 -fsanitize=undefined -fsanitize-undefined-trap-on-error 来处理 not use libubsan rich logging capabilities,但会在未定义指令上捕获它。

    希望其中之一有所帮助。

    【讨论】:

      猜你喜欢
      • 2019-10-27
      • 2017-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-13
      • 2015-08-21
      • 1970-01-01
      • 2021-07-13
      相关资源
      最近更新 更多