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

veryuniquename

Member

Reaction score: 1
Messages: 52

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

Daemon

Reaction score: 1,411
Messages: 2,462

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.
 

eternal_noob

Aspiring Daemon

Reaction score: 382
Messages: 619

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

Reaction score: 11,989
Messages: 38,443

Please don't put a URL in a [thread] bbcode. It royally screws up the layout.
 

oops

Member

Reaction score: 35
Messages: 69

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

 
OP
V

veryuniquename

Member

Reaction score: 1
Messages: 52

-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