ld.exe: 找不到 -lasan ld.exe: 找不到 -lubsan

ld.exe: cannot find -lasan ld.exe: cannot find -lubsan

我正在使用 Clion,我想使用 ASAN address Sanitizer,当我在这里使用 ASAN 编译文件时,出现以下错误:

c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: cannot find -lasan
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: cannot find -lubsan

这是我的CMakeLists.txt内容:

cmake_minimum_required(VERSION 3.17)
project(untitled3)


set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "-Wall -Werror -Wsign-compare")

set(CMAKE_CXX_FLAGS_ASAN "-g -fsanitize=address,undefined -fno-sanitize-recover=all"
        CACHE STRING "Compiler flags in asan build"
        FORCE)

add_executable(untitled3 BinarySearchEasy.cpp)

尚未为 MinGW 启用消毒剂:https://github.com/msys2/MINGW-packages/issues/3163