Ubuntu 16.04 下 mingw 缺少 gcov 符號

Ubuntu 16.04 下 mingw 缺少 gcov 符號

在從 Ubuntu 14.04 升級到 Ubuntu 16.04 之前,我可以使用 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;}

現在由於缺少 __gcov 符號,程式無法連結。

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

兩個 Ubuntu 版本之間發生了什麼變化。任何幫助,將不勝感激。

答案1

我遇到了同樣的問題,我可以透過連結到-fprofile-arcs而不是 來解決它-lgcov

相關內容