Wednesday, February 27, 2013

linker: undefined reference to 'clock_gettime'

while compiling an old project that uses the function clock_gettime on gcc compiler i had the error " undefined reference to 'clock_gettime'", and after minutes of search the solution was to add the real time library "librt.so" or "librt.a" if static linking is needed. add the "-lrt" parameter to gcc if you are compiling manually, and if you are using IDE like codeblocks, from 'settings' , 'compiler' , 'linker settings', 'other linker options' and add "-lrt" then press ok .