lilingmzai
lilingmzai

Reputation: 641

Where are the gcov symbols in android GCC?

I'm trying to compile an android .so file with gcov and getting the following link errors: in function global constructors keyed to 0_XXX:../../source/file1.cpp:2661: error: undefined reference to '__gcov_init' in function .LPBX0:file1.cpp(.data.rel+0x24): error: undefined reference to '__gcov_merge_add' in function global constructors keyed to 0_funcname:../../source/file2.cpp:2154: error: undefined reference to '__gcov_init' in function .LPBX0:file2.cpp(.data.rel+0x24): error: undefined reference to '__gcov_merge_add' ' collect2: ld returned 1 exit status make: * [xxx.so] Error 1

My android makefile change: CFLAGS += --coverage, LOCAL_LDLIBS += --coverage. I can't seem to find the location of the missing symbols. My android toolchain gcc version 4.6. Any ideas? Thanks.

Upvotes: 1

Views: 1737

Answers (2)

user2438949
user2438949

Reputation: 46

change the Android.mk with these 3 lines

1) LOCAL_LDLIBS += -l(absolutepath or relativepath to libgcov)

for eg: LOCAL_LDLIBS += -l/home/souradeep.c/JFLTEATT/android/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/lib/gcc/arm-eabi/4.6.x-google/libgcov.a

2) LOCAL_LDFLAGS += -fprofile-arcs (this is needed for linking important for ur symbol not found problem)

3) LOCAL_CFLAGS += -fprofile-arcs -ftest-coverage

                   or

3) LOCAL_CPPFLAGS += -fprofile-arcs -ftest-coverage

Enjoy.......................................

Upvotes: 0

Ray
Ray

Reputation: 11

You may add following lines to the Android.mk:

LOCAL_CFLAGS += -fprofile-arcs -ftest-coverage

LOCAL_LDFLAGS += -lgcov

Upvotes: 0

Related Questions