I was experimenting with a few timer functions and ended up with the above linker error. Someone on the net suggested to pass -lrt to gcc and it worked! What is '-lrt' and how did it help to overcome this error?
I looked into gcc --help but couldn't find these options and the man page of gcc ( which is too huge ) also dint give much insight into t开发者_开发知识库his.
It adds the rt library to the linker (see librt) which amongst other things defines timer_getoverrun
.
It's not in the gcc man page, because it's not an option. It's a library ( -l
stands for library
, this is the way, libs are passed to the linker)
rt
is a time library. timer_getoverrun
is just defined there.
The timer_getoverrun()
function is implemented in librt.so. From the timer_getoverrun(2)
man page:
SYNOPSIS ... Link with -lrt.
精彩评论