This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: undefined reference to _gcov_init
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Qiong Cai <qiongc at cse dot unsw dot edu dot au>
- Cc: gcc at gcc dot gnu dot org
- Date: Sat, 19 Apr 2003 11:11:26 +0100
- Subject: Re: undefined reference to _gcov_init
- Organization: Codesourcery LLC
- References: <20030419045828.GA12290@cse.unsw.edu.au>
Qiong Cai wrote:
I compiled some program with -fprofile-arcs, but it
failed when linking the object files together:
% make
/import/qin/1/qiongc/gcc-3-4-cvs/bin/gcc -O2 -fprofile-arcs -I/import/qin/1/qiongc/gcc-3-4-cvs/include -I../utils -c LUFactSizeA.c
/import/qin/1/qiongc/gcc-3-4-cvs/bin/gcc -O2 -fprofile-arcs -I/import/qin/1/qiongc/gcc-3-4-cvs/include -I../utils -c LUFact.c
/import/qin/1/qiongc/gcc-3-4-cvs/bin/gcc -o LUFactBenchSizeA LUFactSizeA.o LUFact.o -L/import/qin/1/qiongc/gcc-3-4-cvs/lib -lm -L../utils -lgetclock
LUFactSizeA.o(.text+0x5e): In function `_GLOBAL__I_main_GCOV':
: undefined reference to `__gcov_init'
LUFact.o(.text+0x197e): In function `_GLOBAL__I_datasizes_GCOV':
: undefined reference to `__gcov_init'
../utils/libgetclock.a(getclock.o)(.text+0x6d): In function `_GLOBAL__I_getclock_GCOV':
: undefined reference to `__gcov_init'
../utils/libgetclock.a(gtod.o)(.text+0xb0): In function `_GLOBAL__I_starttime_GCOV':
: undefined reference to `__gcov_init'
collect2: ld returned 1 exit status
On the link line you have to either
a) add -fprofile-arcs
b) add -lgcov
I see the manual is not clear on this, I'll fix that.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
The voices in my head said this was stupid too
nathan at codesourcery dot com : http://www.cs.bris.ac.uk/~nathan/ : nathan at acm dot org