I am working, for the first time, with the coverage tool gcov to analyze a large project. I have a directories structure like this:
HW
-FooHW1.cpp
-FooHW1.h
-FooHW2.cpp
-FooHW2.h
-...
-Makefile.am
Lib1
-FooLib1.cpp
-FooLib1.h
-FooLib2.cpp
-FooLib2.h
-...
-Makefile.am
Lib2
...
-Makefile.am
Lib3
...
-Makefile.am
Main
-main.cpp
-main.h
-Makefile.am
Each directory has its own Makefile generated using automake to generates dependecies and whatsoever where the compiler used is c++.
Since my objective is the analyses of the statement coverage I tried to use gcov adding the following lines to each Makefile.am to generate my .gcno and .gcda files in order to use gcov:
AM_CXXFLAGS = -fprofile-arcs -ftest-coverage
AM_LDFLAGS = -fprofile-arcs
Unfortunately even if it compiles it doesn't create (or link) the several *.o and when invoking gcov it usually gives me the error:
undefined __gcov_init
I also tried susbtituing, according to http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#index-coverage-536, the upper instructions to:
AM_CXXFLAGS = --coverage
AM_LDFLAGS = --coverage
but it doesn't do the trick for me.
I would like to specify that this is the first experience with the gcov tool and in dealing with large c++ projects. Thaks for your help.