problem with gcov, cannot run
Andrew Mclaughlin
So i'm trying to optimize a file called linpack.c. I have to use gcov to find the 10 most executed lines. I've been given these compiler options:
-fprofile-arcs -ftest-coverage -O2So i ran this
$ gcc -fprofile-arcs -ftest-coverage -O2 linpack.cthe output was linpack, linpack.gcno.
Now when I try to run gcov linpack.c in order to generate linpack.c.gcov I get an error:
linpack.gcda, cannot open data file.Can someone tell me what I'm doing wrong? This should be straightforward but I have been struggling for more than an hour now.
1 Answer
The linpack.gcda file should get created when you execute the program that you compiled with the profile flags. Since you didn't supply an output file name (using the -o option) on the gcc command line, you will need to execute it as a.out. For example:
$ gcc -fprofile-arcs -ftest-coverage -O2 hello.c
$ ls hello.*
hello.c hello.gcno
$
$ ./a.out
Hello world!
$ ls hello.*
hello.c hello.gcda hello.gcno
$