Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-14-2010, 07:16 AM   #1
LQ Newbie
Registered: Jun 2009
Posts: 5

Rep: Reputation: 0
Using gcov


I am using gcov to get code coverage for my program written in C++, I am able to do it without any problem when i don't have a directory structure, for my program I am a directory structure as below

./src/ -- containing all my source files

./obj/ -- containing all my object files

./header/ -- containing all my header files

../../lib/  -- containing a static library, which will be used by 
                my program 

there is a makefile in the current directory which creates my executable
do i need to compile the static library also with the options of gcov i.e. -fprofile-arcs -ftest-coverage, because it is the library that i need to check for coverage.
Kindly help on how use gcov in this situation.
Old 09-15-2010, 01:07 AM   #2
Registered: May 2010
Posts: 83

Rep: Reputation: Disabled
Hi -

Yes, if you want to profile an object file, then you need to compile that object with " -fprofile-arcs -ftest-coverage", regardless of whether you link directly to that object, or put it in a static library and then link to the library.

You should keep your .da files. And you should probably run "gcov" with -p and -l.

'Hope that helps



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
compiling with gcov flags -fprofile-arcs and -ftest-coverage fails. sanjay_mishra Linux - General 1 12-02-2009 04:06 AM
[SOLVED] Problem with LCOV GCOV graemef Programming 1 08-26-2009 01:07 AM

All times are GMT -5. The time now is 09:55 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration