C/C++ cannot find -lasan when doing -fsanitize=address using GCC/g++/etc

Issue: Using any compiler to compile any C code with "-fsanitize=address" results in the following error:
Code:
/usr/local/bin/ld: cannot find -lasan
collect2: error: ld returned 1 exit statu

I get this error even when I try gcc main.c -fsanitize=address on
Code:
int main() {
    return 0;
}


using -L/usr/local/lib -I/usr/local/include yields the same result as above.
I found this thread:
 

zirias@

Developer
Using any compiler to compile any C code with "-fsanitize=address"
What's "any compiler"? Did you just try the system's default compiler cc? (This should be clang nowadays, not sure there are still platforms using gcc, but definitely not the x86 platforms)
I get this error even when I try gcc main.c -fsanitize=address on
Where does this gcc come from? The GCC ports on freebsd install binaries with a version suffix, e.g. gcc10. But then again, just use cc.
 
The original post broke the HTML markup. The posts are now side by side instead top to bottom.

htmlspecialchars, anyone?

Edit: Fixed, thanks.
 

SirDice

Administrator
Staff member
Administrator
Moderator
Please don't put a URL in a [thread] bbcode. It royally screws up the layout.
 
-fsanitize=address on FreeBSD is only supported on amd64 and i386 by Clang (default compiler) and GCC >= 11 (e.g., lang/gcc11-devel).

 
-fsanitize=address on FreeBSD is only supported on amd64 and i386 by Clang (default compiler) and GCC >= 11 (e.g., lang/gcc11-devel).

Thanks a lot! This fixed it.
 
Top