1
votes

Steps to Reproduce the issue

#include<iostream>
int main(){
    std::cout <<  "Hello World" << std::endl;
}
  1. Write main.cpp

  2. Download Toolchain from this link

  3. Compile with below commands.

    • . /opt/poky/1.6/environment-setup-armv7a-vfp-neon-poky-linux-gnueabi
    • arm-poky-linux-gnueabi-g++ main.cpp -o main --coverage
  4. Will get an error like below.

Error

/opt/poky/1.6.1/sysroots/i686-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.8.3/ld: cannot find -lgcov collect2: error: ld returned 1 exit status

Problem Statement

How to generate a libgcov.so file for ARM poky toolchain?

-fprofile-args --coverage -ftest-coverage

I'm able to generate a the code coverage report using x86 linux g++ compiler by installing

- sudo apt-get install gcovr
- g++ main.cpp -o main --coverage

Is there any source code or git repository from which I can generate the libgcov.so file for the ARM poky toolchain? Or Is there any solution to get the coverage of a program from ARM poky toolchain?

I have tried cloning and compiling the below repository as a library but the issue is not resolved.

https://github.com/reeteshranjan/libgcov-embedded

How to generate the code coverage report file for a program written using ARM toolchain(poky 1.6) on Ubuntu 18.04?

Is there any source code github.com/gcovr/gcovrKamilCuk
After adding the -coverage flag, we are getting gcno files but not gcda file. Gcda file is having the coverage information which is not getting generated hence the coverage is shown as 0Thomas Easo
Gcda file Is not generated since it’s throwing a linker error unable to find -lgcovThomas Easo
Gcov is part of GCC, and can't really be distributed separately. If the linker fails to resolve this, this could indicate that your cross-compilation configuration is broken. I haven't done so myself, but I know of people who have used gcov and gcovr on ARM successfully. There is no GCC 8.25, maybe that's part of the problem? Most recent 8.x release is 8.4.amon
You must use the gcov binary from the cross-compilation toolchain, not the gcov from your default GCC installation. If you invoked the compiler as /some/path/g++-8 you need to use /some/path/gcov-8. When you later use gcovr, you must also provide this path as the --gcov-executable. This will get rid of the version warning, but if the "no function found" error persists then the .gcda is still empty.amon