1

Before upgrading from Ubuntu 14.04 to Ubuntu 16.04 I could compile the following code with mingw-64-gcc

x86_64-w64-mingw32-gcc -fprofile-generate -o test.exe test.c -lgcov -static

//test.c
#include <stdio.h>
int main(void)
{puts("test");return 0;}

Now the program cannot be linked due to missing __gcov symbols.

x86_64-w64-mingw32-gcc -fprofile-generate -o test test.c
/tmp/cccj8pnx.o:test.c:(.text+0x1a): undefined reference to `__gcov_indirect_call_profiler_v2'
/tmp/cccj8pnx.o:test.c:(.text+0x46): undefined reference to `__gcov_time_profiler'
/tmp/cccj8pnx.o:test.c:(.data+0xa0): undefined reference to `__gcov_merge_time_profile'
/tmp/cccj8pnx.o:test.c:(.rdata$.refptr.__gcov_indirect_call_callee[.refptr.__gcov_indirect_call_callee]+0x0): undefined reference to `__gcov_indirect_call_callee'
collect2: error: ld returned 1 exit status

What has changed between between the two Ubuntu versions. Any help would be appreciated.

tetram
  • 11
  • 2

1 Answers1

0

I ran into this same problem, and I was able to work around it by linking to -fprofile-arcs rather than -lgcov.

  • This does indeed make the link succeed, but running doesn't produce any .gcda files and is thus useless. I noticed that `libgcov.a` is practically empty (still, on Ubuntu 19.10). Can't find any trace what changed and why. – Jan Wielemaker Dec 15 '19 at 14:17