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:
- Make clean (remove all of my .o and lib files).
- Ensure every source file has the correct options (-fprofile-arcs -ftest-coverage).
- Ensure every shared library the source files are compiled into specify -lgcov
- Ensure I link the executable with -lgcov.
See also this answer and this blog post.
精彩评论