gcov final link failed

只谈情不闲聊 提交于 2019-12-23 17:33:40

问题


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

Following are flags information i have while compiling

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?


回答1:


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.



来源:https://stackoverflow.com/questions/5900744/gcov-final-link-failed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!