1

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

Community
  • 1
  • 1
Mathai
  • 839
  • 1
  • 12
  • 24

1 Answers1

0

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.

Misguided
  • 1,302
  • 1
  • 14
  • 22
  • that worked thanks! ... i just didnt know it was rt, I have been trying -lrt..So it's really -l rt right? – Mathai Dec 28 '11 at 03:55
  • -l is the parameter saying that you're linking to librt (rt is the actual name, but lib is always in front of any lib's name). Remember to accept the answer. – Misguided Dec 28 '11 at 03:57
  • sorry i didnt know that .. new to the forum.. thanks again. I just accepted your answer. – Mathai Dec 28 '11 at 04:04
  • Its ok, that's all theres to it. Good luck with your project. – Misguided Dec 28 '11 at 05:18