can gcov deal with shared object?

若如初见. 提交于 2019-12-03 21:47:12

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/3709699/can-gcov-deal-with-shared-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!