PDA

View Full Version : Gcov with Qt



maninc
4th May 2009, 11:04
Hi,

I am trying to compile my code to check Coverage. i have used "-fprofile-arcs -ftest-coverage" option while compiling my code using GCC. Neither i get any .da / .bb / .gcda files or .gcov files after running the application.

I tried using the hack specified in the link below
http://www.qtcentre.org/forum/f-general-programming-9/t-qmake-and-gcov-15427-post78633.html But i still face the same issue.

Am i missing some thing or Is there any other configuration needed to use Gcov.

Thanks in advance.

Mani

wysota
4th May 2009, 12:35
Did you build the application in debug mode?

maninc
4th May 2009, 12:58
Yes i did compile it with debug mode (-g)

maninc
4th May 2009, 13:10
Hi,

When i give "make" this is what it does,


gcc -c -pipe -fprofile-arcs -ftest-coverage -g -D_REENTRANT -Wall -W -DQT_DBUS_LIB -DQT_SVG_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I<Include Path> -o ./applicationwindow.o applicationwindow.cpp

Is there any mistake in the above command ?

Mani

wysota
4th May 2009, 14:15
I think this is not enough. You also need to link with the gcov library and pass the same flags to the linker. Here is something that worked for me:
QMAKE_CXXFLAGS += -fprofile-arcs -ftest-coverage
QMAKE_LDFLAGS += -fprofile-arcs -ftest-coverage
LIBS += -lgcov

maninc
4th May 2009, 15:10
I tried this option as well. No luck yet :(

wysota
4th May 2009, 15:43
I assure you it works fine for me. Please check if all relevant files are compiled with the mentioned options.

maninc
5th May 2009, 14:01
Found out the issue. I had to Disable ccache to get the gcno and gcda file to be directed to sourec directory.

Thanks for the help :)

Mani