undefined reference to `memset'

Peter Jeremy PeterJeremy at optushome.com.au
Wed Mar 23 23:05:25 PST 2005


On Wed, 2005-Mar-23 13:48:04 -0800, Vinod Kashyap wrote:
>If any kernel module has the following, or a similar line in it:
>-----
>char x[100] = {0};
>-----
>building of the GENERIC kernel on FreeBSD 5 -STABLE for amd64
>as of 03/19/05, fails with the following message at the time of linking:
>"undefined reference to `memset'".
>
>The same problem is not seen on i386.
>
>The problem goes away if the above line is changed to:
>-----
>char x[100];
>memset(x, 0, 100);
>-----

Can you post a complete (compilable) example please.  Based on your
second example, I suspect that you are putting the variable
declaration inside a function definition - the second example doesn't
make sense outside a function.

If I add "char x[100] = {0};" into a function on i386 and compile it
as a kernel module on 5.3, a static memset symbol is generated - it's
possible that the amd64 compiler gets confused about the implicit
reference to memset that this code needs.

-- 
Peter Jeremy


More information about the freebsd-stable mailing list