title: Run gcov tool using c++ compiler
body: <p>I am working, for the first time, with the coverage tool gcov to analyze a large project.
  I have a directories structure like this:</p>
  
  <pre><code>    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
  </code></pre>
  
  <p>Each directory has its own Makefile generated using automake to generates dependecies and whatsoever where the compiler used is c++.</p>
  
  <p>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:</p>
  
  <pre><code>    AM_CXXFLAGS = -fprofile-arcs -ftest-coverage
      AM_LDFLAGS = -fprofile-arcs
  </code></pre>
  
  <p>Unfortunately even if it compiles it doesn't create (or link) the several *.o and when invoking gcov it usually gives me the error:</p>
  
  <pre><code>    undefined __gcov_init
  </code></pre>
  
  <p>I also tried susbtituing, according to <i><a href="http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#index-coverage-536" rel="nofollow">http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#index-coverage-536</a></i>,  the upper instructions to:</p>
  
  <pre><code>    AM_CXXFLAGS = --coverage
      AM_LDFLAGS = --coverage
  </code></pre>
  
  <p>but it doesn't do the trick for me.</p>
  
  <p>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.</p>