gcov: cannot open graph file

Caleb Poucher picture Caleb Poucher · Jul 25, 2011 · Viewed 14.9k times · Source

I am trying to use gcov. I have this simple file a.c:

int main() {
   return 0;
}

So I do

gcc -fprofile-arcs -ftest-coverage a.c -o a
./a
gcov a.c

and I get

a.gcno:cannot open graph file

Am I doing something wrong? I'm under Mac OS X Lion.

Answer

Steve Atkins picture Steve Atkins · Sep 13, 2011

By default on Lion, "gcc" is not gcc. It's LLVM. And it doesn't support generating test coverage data.

If you run gcc-4.2 -fprofile-arcs -ftest-coverage a.c -o a instead that will use a real gcc, and it'll probably work.