如何在 GCC 中使用 AddressSanitizer? [英] How to use AddressSanitizer with GCC?
本文介绍了如何在 GCC 中使用 AddressSanitizer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用
g++ -O0 -g -fsanitize=address -fno-omit-frame-pointer
但是会出现很多错误,例如:
but get lots of errors like:
/home/user/libs/opencv/include/opencv2/core/mat.hpp:715: undefined reference to `__asan_report_load8'
如何编译支持 AddressSanitize 的项目?
How to compile project with AddressSanitize support?
我的 gcc 版本是 4.8.4.
My gcc version is 4.8.4.
推荐答案
需要添加开关-lasan
-fsanitize=address
到您的两者编译和链接命令行以链接正确的库.
You need to add the switch -lasan
-fsanitize=address
to your both your compile and link command line to link the correct library.
注意:根据评论,原始答案 -lasan 已过时,不应使用
Note: the original answer -lasan is outdated and should not be used, as per comments
这篇关于如何在 GCC 中使用 AddressSanitizer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文