Gcov final link failed

When compiling my project with gcov support, I encountered the error below

Below are the data of the flags that I have when compiling

compiler flags:

CXXFLAGS="-Wno-deprecated -g -ggdb -fprofile-arcs -ftest-coverage -fPIC"

linker options:

LINK_CMD="gcc -fprofile-arcs -fPIC"

The following is version information:

Gcc version:

gcc version 4.1.2 20080704 (Red Hat 4.1.2-44)

gcov version:

gcov (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44)

Error:

hidden symbol `__gcov_init 'in / usr / lib / gcc / x86_64-redhat-linux / 4.1.2 / libgcov.a (_gcov.o) refers to DSO / usr / bin / ld: final link failed: unrepresentative output section collect2: ld returned 1 exit status

Could you help me avoid this problem?

+3
source share
1 answer

, :

  • ( .o lib).
  • , (-fprofile-arcs -ftest-coverage).
  • , , -lgcov
  • , -lgcov.

. .

+4

All Articles