I am trying to compile a program that uses the function clock_gettime. The man page on Ubuntu says it has to be compiled with -lrt option.
If I issue the command
gcc myprogram.c -lrt
my program compiles fine.
Now how do I add the option -lrt to Eclipse. I already tried adding -lrt to:
GCC Compiler->Miscellaneous->Other flags and GCC C Linker->libraries
This question is posted here – however the answer does not seem to help me.
Compiling in Eclipse with gcc's -lpthread and -lrt set
Its been a long time since I last used eclipse, but there should be a + button in the section you mentioned (GCC compiler -> etc -> libraries). Just click on it and write rt, then click on it again and write pthread, that should be it (to add both libraries, of course).
EDIT: nevermind, the post you mentioned says it should be in the Build section, but you’ll see there’s a + button, thats for sure.