0

I have this function:

void Estatisticas::iniciarTempo() {

clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tempoInicial); 

}

I'm trying to use clock_gettime by ctime, but I getting some errors:

"undefined reference to 'clock_gettime'"

Thanks a lot.

Breno
  • 27
  • 4

1 Answers1

0

From the clock_gettime/clock_getres manpage:

Link with -lrt.

The symbol is defined in the POSIX Real Time library. Add "-lrt" to your compilation line:

gcc -lrt -o myprog myprog.c
Mike Andrews
  • 3,045
  • 18
  • 28