-1

I have a C++ app where I use some C functions. I have declared those C functions inside extern "C" {}; And it is compiling and working just fine. I am using 'gcc' for compiling the C code, and using 'g++' for linking that object with C++ object.

GCOV fails by throwing me the following error:

hidden symbol `__gcov_init' in /usr/lib/gcc/x86_64-linux-gnu/5/libgcov.a(_gcov.o) is referenced by DSO
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

I have no idea as this is new to me combining C and C++ code. Any one have idea why "gcov" failing with linking stage. If I disable those "C" functions in my app then it "gcov" is not giving me that error.

C Functions I am using just initialising a struct which has function pointers in it with some functions.

Any help is really appreciated.

Thanks

too honest for this site
  • 12,050
  • 4
  • 30
  • 52
Dinesh G
  • 129
  • 7

1 Answers1

0

I was able to fix it by adding "-lgcov" flag while linking, but I don't know why it did not work even though "--coverage" flag should do the linking for this. Only have this problem when linking C object file with C++ object.

Here is the link for the answer: link

Dinesh G
  • 129
  • 7