Underfined reference clock_gettime not solved b...

underfined-reference-clock-gettime-not-solved-by-lrt

up vote 0 down vote favorite

I'm trying to compile the program the source for which is here. As per his instructions I'm compiling using the command g++ -O3 -lrt netmon.cpp -o netmon. I get this output:

netmon.cpp:(.text.startup+0xb3): undefined reference to `clock_gettime'
collect2: ld returned 1 exit status

This is odd as I have read that the rt library provides this function. What is going on?

c++  compiling
share improve this question
edited  Jul 13 '12 at 3:36
Jeremy Kerr
4,300928
asked  Jul 13 '12 at 2:40
sennett
1285

2 Answers

ACTIVE OLDEST VOTES

up vote 1 down vote

gcc and g++ can be picky about the order of link arguments. In general, you should specify library arguments (-l) after local objects. Try this instead:

g++ -O3 netmon.c -o netmon -lrt
share improve this answer
answered  Jul 13 '12 at 3:30

你可能感兴趣的:(Underfined reference clock_gettime not solved b...)