views:

81

answers:

1

Hi, All 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  A: 

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: http://stackoverflow.com/questions/3712908/gcov-producing-gcda-output-from-shared-library/3755038#3755038. It also references the same thread above.

deuberger
Thank you, it seems gcov cannot collect coverage data against shared object...
maguschen
Actually, I think it does now. See my edit.
deuberger