GCC链接ASAN后运行报错:

ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD" runtime error.

可能有多种方式解决(请逐一尝试):
1、依赖的库列表中,将asan放到第一个
2、程序运行依赖中,入口程序添加asan支持,之后的程序都可以不加,否则报此错误。如A运行需要依赖B程序,则B作为入口程序添加asan即可,A不添加也能生效
3、export LD_PRELOAD=/usr/lib64/libasan.so.5    (Linux asan的库位置)
4、添加编译选项:-fsanitize=address
5、动态链接 -lasan 改为 静态链接 -static-libasan
6、export ASAN_OPTIONS=verify_asan_link_order=0禁用检查(仅高版本gcc支持)

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐