I try to test an executable which uses OpenCV shared library. When using gcov to know what code lines were covered I only get info about my .cpp files and .hpp of the library. No info is shown about .cpp files of the library.
I compiled and linked with -pg --coverage flags.
Yes, gcov can give coverage information about a shared library. If I remember correctly from the problems I had getting this to work on my project, you're probably not including the
--coverage
flag on the linking of the dynamic library. Here's the smallest example I could create.Makefile:
myexec.cpp:
mylib.h
mylib.cpp
Output of make (so you can see exactly what the build was):
I ran the executable using
LD_LIBRARY_PATH="." ./myexec a
, and then rangcov mylib.cpp
. Here's the contents of mylib.cpp.gcov: