"未定义的符号_memset" [英] "Undefined Symbol _memset"

查看:4588
本文介绍了"未定义的符号_memset"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我问过类似的问题,但我有一些更新,其中实在是困惑我。从本质上讲,我想和链接器链接一些对象文件如下:

I asked a similar question, but I have some update which is really confusing me. Essentially, I want to link a number of object files with the linker as follows:

/usr/ccs/bin/ld -o q -e start_master -dn -z defs -M ../../../mapfile.q {list of object files}

我收到以下错误:

I get the following error:

Undefined                       first referenced 
 symbol                             in file
_memset                             reconf.o

有趣的事情是,这memset的不reconf.c引用,我也grep'ed整个目录,但也有没有参考任何其他文件,以_memset。因此,我很奇怪,为什么我得到的链接此错误信息,但无处在我的源$ C ​​$ C _memset实际使用。任何人的想法可能是怎么回事?

The interesting things is, that memset is not referenced in reconf.c and I also grep'ed the whole directory but there is also no reference in any of the other files to _memset. Therefore I am wondering why I get this error message from the linker, although nowhere in my source code _memset is actually used. Anyone an idea what could be going on here?

太感谢了,这个错误是推动我们精神!

Thanks so much, this error is driving us mental!

编辑:

我试图路径添加到memset的图书馆,并与-lc链接,并在详细模式下运行:

I tried to add the path to the library of memset and linked it with -lc and run it in verbose mode:

/usr/ccs/bin/ld -o q -e start_master -dn -z defs -z verbose -L/usr/lib -M ../../../mapfile.q {list of object files} -lc

然后我得到以下错误:
    LD:致命的:库-lc:未找到
    LD:致命的:文件处理错误。无输出写入到q

Then I get the following error: ld: fatal: library -lc: not found ld: fatal: File processing errors. No output written to q

这虽然libc.so显然是在/ usr / lib中...

And this although libc.so is clearly in /usr/lib ...

混淆

编辑II:

做一些更多的研究,似乎在Solaris 10上静态链接disappeard,你可以在这里阅读:

Doing some more research it seems that on Solaris 10 static linking disappeard as you can read here:

http://blogs.oracle.com/rie/entry/static_linking_where_did_it

也许这是我的问题。有没有人一个想法,我怎么可以重写我的链接器命令的解决方法,这个问题?

Probably this is my problem. Has anyone an idea how I could rewrite my linker command for a workaround to this problem?

非常感谢!

推荐答案

也许你所做的:

struct S v = { 0 };

struct S v;
v = (some const-variable).

uint8_t b[100] = { 0 };

一些编译器是把隐含内置的memset(或者memcpy的)这样的事情。内置的memset则称为_memset(你的情况)。一旦你的链接和您的libc(或者什么你的情况提供了标准的功能)不providie,你收到此链接错误。

Some compilers are putting implicitly the built-in memset (or memcpy) for such things. The built-in memset then is called _memset (in your case). Once you link and your libc (or what provides standard-function in your case) does not providie it, you are getting this link error.

这篇关于"未定义的符号_memset"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆