gcov 可以处理共享对象吗?
我最近使用 gcov 来收集代码覆盖率信息。 gcov 与可执行应用程序配合得很好:),但是当我尝试加载 .so 文件时,出现此错误:未知符号 __gcov_merge_add。
然后我在谷歌上搜索,有人说添加 -lgcov 到链接标志(LDFLAGS),我确实添加了这个选项,但它不起作用。我还尝试在链接标志中使用 --coverage 选项,但无法消除此错误。
有人可以帮助解决这个问题吗?
谢谢。
I am recently using gcov to collect the code coverage info. gcov plays well with executable application :) , but when I try to load a .so file, I got this error: unknown symbol __gcov_merge_add.
Then I search on Google and someone said adding -lgcov to the link flag(LDFLAGS), I did add this option and it didn't work. I also try on --coverage option in link flag, cannot get rid of this error.
Can someone help on this issue?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也遇到了这个问题,但后来解决了。我只是在 CPPFLAGS 和 LDFLAGS 中使用 --coverage 选项。我认为这应该可以解决你的编译问题。
不过,共享对象似乎仍然没有生成 .gcda 文件,我不确定如何解决该问题。就像你说的,它对于可执行文件工作得很好,但是共享对象似乎有一些问题。
编辑:
显然,gcov 现在确实支持共享对象。我昨天做了大量研究,发现了相互矛盾的答案,所以我邮寄了 gcc-help 列表。请参阅此处的线程: http://gcc.gnu.org/ ml/gcc-help/2010-09/msg00130.html。我还没有尝试根据答案解决我的问题,但当我这样做时我会回复。
编辑2:
共享对象确实可以与 gcov 一起使用(或者而不是与 gcc 一起使用 --cover 选项)。这里还有另一篇详细信息的文章: gcov:生成 .gcda 输出共享库?。它还引用了上面的同一线程。
I ran into that problem too, but have since solved it. I just use the --coverage option in both CPPFLAGS and LDFLAGS. I think that should take care of the compile issue for you.
The shared object still doesn't seem to produce .gcda files though and I'm not sure how to solve that problems. Like you said, it works fine with executables, but shared objects seem to have some problems.
EDIT:
Apparently, gcov does support shared objects now. I did a significant amount of research yesterday and found conflicting answers, so I mailed the gcc-help list. See thread here: http://gcc.gnu.org/ml/gcc-help/2010-09/msg00130.html. I haven't tried solving my problem based on the answer yet, but I will post back when I do.
EDIT 2:
Shared objects do work with gcov (or rather than --cover option with gcc). There's another post with details here: gcov: producing .gcda output from shared library?. It also references the same thread above.