I am trying to compile a simple application with gcov and get the following link errors:
gcc AllTests.o CuTestTest.o CuTest.o -o TestTest AllTests.o: In function `global constructors keyed to 0_RunAllTests': /home/p7539c/cutest/AllTests.c:26: undefined reference to `__gcov_init' AllTests.o:(.data+0x44): undefined reference to `__gcov_merge_add' CuTestTest.o: In function `global constructors keyed to 0_TestCuStringNew': /home/p7539c/cutest/CuTestTest.c:30: undefined reference to `__gcov_init' CuTestTest.o:(.data+0x64): undefined reference to `__gcov_merge_add' CuTest.o: In function `global constructors keyed to 0_CuStrAlloc': /home/p7539c/cutest/CuTest.c:379: undefined reference to `__gcov_init' CuTest.o:(.data+0x184): undefined reference to `__gcov_merge_add' collect2: ld returned 1 exit status make: *** [TestTest] Error 1
I can't seem to find the location of the missing characters. gcov is present on a machine running gcc version 4.1.2
Any ideas? Thank.
In the editor:
Everything seems to work just fine when using gcov with an application that consists of a single .c file. When I have multiple .c files (hence multiple .o files), I have a problem.
The compilation steps are as follows:
cc -fprofile-arcs -ftest-coverage -g -c -o AllTests.o AllTests.c cc -fprofile-arcs -ftest-coverage -g -c -o CuTestTest.o CuTestTest.c cc -fprofile-arcs -ftest-coverage -g -c -o CuTest.o CuTest.c
gcc profile gcov
john146 Feb 19 '09 at 18:06 2009-02-19 18:06
source share