开发者

gcov final link failed

While compiling my project with gcov support I am facing the below error

Following are flags information i have while com开发者_如何学Pythonpiling

compiler flags:

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

linker options:

LINK_CMD="gcc -fprofile-arcs -fPIC"

Following are 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) is referenced by DSO /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: ld returned 1 exit status

Could you please help me to get away from this problem?


I have been able to solve this problem in my own code using these steps:

  1. Make clean (remove all of my .o and lib files).
  2. Ensure every source file has the correct options (-fprofile-arcs -ftest-coverage).
  3. Ensure every shared library the source files are compiled into specify -lgcov
  4. Ensure I link the executable with -lgcov.

See also this answer and this blog post.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜