Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libgcov profiling error - overwriting an existing profile data with a different timestamp

Tags:

c++

c

gcov

gcovr

My issue is different than this question: the problem there was that he was compiling the same file twice.

I am only compiling each file once.

g++ -c "file_1.c" -o file_1.o  -fprofile-arcs -ftest-coverage  
g++ -c "file_2.c" -o file_2.o  -fprofile-arcs -ftest-coverage
g++ -c "file_3.c" -o file_3.o
g++ file_1.o file_2.o file_3.o -lgcov --coverage

Then when I run it, I get the error:

./a.exe
libgcov profiling error:file_1.gcda:overwriting an existing profile data with a different timestamp
libgcov profiling error:file_2.gcda:overwriting an existing profile data with a different timestamp
...

QUESTION
Why is there an error given that I only compile each instrumented file once unlike the linked question?

like image 921
Bob Avatar asked Nov 02 '25 12:11

Bob


1 Answers

I had the same problem when compiling criterion in C, and found this website which explained what the origin of the error was and how to solve it. Turns out the problem was that Criterion uses file names to create its object files, and I had a file named src/str.c and a file named tests/str.c, which tested the src/str.c file.

Because those two files had the same name, even tough they were not in the same directory, Criterion encountered problems when creating object files.

You can fix this issue by changing the files' name. For example, I changed the tests/str.c into a tests/test_str.c.

If this doesn't work, you can also try removing the .gcno and .gcda files before executing the program.

like image 170
TheVietCoder Avatar answered Nov 04 '25 02:11

TheVietCoder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!