gcov を使用して単純なアプリをコンパイルしようとすると、次のリンク エラーが発生します。
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
不足しているシンボルの場所が見つからないようです。gcov は、gcc バージョン 4.1.2 を実行しているマシンに存在します。
何か案は?ありがとう。
編集時:
1 つの .c ファイルで構成されるアプリケーションで gcov を使用すると、すべて正常に動作するようです。複数の .c ファイル (したがって複数の .o ファイル) がある場合、上記の問題が発生します。
コンパイル手順は次のようになります。
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