Search code examples
c++clionaddress-sanitizer

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


I am using Clion and I want to use ASAN address Sanitizer, when I compile the file with ASAN here I get the following errors:

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

Here is my CMakeLists.txt content:

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)

Solution

  • Sanitizers have not yet been enabled for MinGW: https://github.com/msys2/MINGW-packages/issues/3163