undefined reference to _gcov_init

Nathan Sidwell nathan@codesourcery.com
Sat Apr 19 14:00:00 GMT 2003


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@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org




More information about the Gcc mailing list