-   Programming (
-   -   Using gcov (

niranjanvg 09-14-2010 06:16 AM

Using gcov

I am using gcov to get code coverage for my program written in C++, I am able to do it without any problem when i don't have a directory structure, for my program I am a directory structure as below


./src/ -- containing all my source files

./obj/ -- containing all my object files

./header/ -- containing all my header files

../../lib/  -- containing a static library, which will be used by
                my program

there is a makefile in the current directory which creates my executable


do i need to compile the static library also with the options of gcov i.e. -fprofile-arcs -ftest-coverage, because it is the library that i need to check for coverage.

Kindly help on how use gcov in this situation.

14moose 09-15-2010 12:07 AM

Hi -

Yes, if you want to profile an object file, then you need to compile that object with " -fprofile-arcs -ftest-coverage", regardless of whether you link directly to that object, or put it in a static library and then link to the library.

You should keep your .da files. And you should probably run "gcov" with -p and -l.

'Hope that helps

All times are GMT -5. The time now is 04:43 PM.