- 1 year ago
How to generate .gcov intermediate text file with windows Mingw compiler and how lcov can use those .gcov file?
Comment
1 / 1
To generate .gcov intermediate text files using the Windows Mingw compiler and use lcov to process them, you can follow these steps:
Step 1: Install Mingw-w64
- Download and install the Mingw-w64 compiler for Windows from the official website (https://mingw-w64.org/doku.php).
Step 2: Compile your code with gcov support
- Open a command prompt or terminal and navigate to the directory containing your source code.
- Compile your code with the following flags to enable gcov support:
Replace "yourprogram" with the name of your source code file.gcc -fprofile-arcs -ftest-coverage -o yourprogram yourprogram.c
Step 3: Run your program
- Execute your program through the command prompt or terminal.
Step 4: Generate .gcov files
- After running your program, gcov will generate .gcov files for each source code file.
- Use the following command to generate .gcov files:
Replace "yourprogram.c" with the name of your source code file.gcov yourprogram.c
Step 5: Install lcov
- Download and install lcov from the official website (https://github.com/linux-test-project/lcov).
Step 6: Process .gcov files with lcov
- Open a command prompt or terminal and navigate to the directory containing the .gcov files.
- Use the following command to generate an lcov report:
This command captures coverage data from the .gcov files and saves it to the coverage.info file.csslcov --capture --directory . --output-file coverage.info
Step 7: Generate HTML report
- Use the following command to generate an HTML report from the coverage.info file:
This command will generate an HTML report in the coverage_html directory.cssgenhtml coverage.info --output-directory coverage_html
Step 8: Open the HTML report
- Open the coverage_html/index.html file in a web browser to view the coverage report.
By following these steps, you should be able to generate .gcov intermediate text files using the Windows Mingw compiler and process them with lcov to generate a coverage report in HTML format.