Unable to find GCC Code coverage libgcov.so for arm toolchain

1.3k views Asked by At

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?

1

There are 1 answers

0
Thomas Easo On BEST ANSWER
  1. Build the application using yocto build system

    bitbake

  2. Copy the libgcov.so generated from /tmp/deploy/ into /opt/poky/1.6.1/sysroots/i686-pokysdk-linux/usr/lib/

  3. Trigger the build using g++