-4

I want to use the time.h library. For this I need the header and the code of the library itself. An .so file which contains the implementation of the header declarations.

How can I find out which .so file corresponding to my header? And where can I get this file if it is not in on my system?

I use a self made Makefile and a powerpc-linux-gcc.

Manfred
  • 159
  • 5
  • 17

1 Answers1

3

How can I find out which .so file corresponding to my header?

Since <time.h> is part of the standard C library, it will always be libc.so.

And where can I get this file if it is not in on my system?

It is.

Edit: seems that on Ubuntu you have to link against librt.so.

  • Thanks for the answer. I included `libc.so` with `-lc` in make file. But still the linker error `undefined reference to clock_gettime'` appears. `clock_gettime` is in the `time.h` .So what is the problem? – Manfred Sep 20 '12 at 06:26
  • @Manfred you don't need to supply `-lc` to the linker, it's included automatically. You're doing something else wrong. Maybe your system doesn't have this function. –  Sep 20 '12 at 06:29
  • But I used the library `semaphore.h` and I also get error messages. Than I supply `lpthread` to the linker and it works. How is it possible that my system doesn't have this function if I have `time.h` in the `/user/include/` directory?`And by the way If I don't have a person which tell me that `time.h` corresponding to `libc.so` how can I find out that by my own. – Manfred Sep 20 '12 at 06:34
  • @Manfred which distribution of Linux are you using? I just checked and on Ubuntu you have to link to `librt.so`... –  Sep 20 '12 at 06:36
  • That'S it. Thanks a lot. I use Ubuntu on my development environment. Can you tell me how you `checked`it? And a second problem. I have this lib on my Host but not on the target. Is there a problem? And can I just copy it? If not where can I get it? – Manfred Sep 20 '12 at 06:42
  • @Manfred btw I just googled "linux clock_gettime linker error" and the [first hit was this SO question...](http://stackoverflow.com/questions/2418157/ubuntu-linux-c-error-undefined-reference-to-clock-gettime-and-clock-settim) –  Sep 20 '12 at 06:48
  • @Manfred try running the compiled program on the machine which doesn't have librt.so also. If it works, that's fine. If not, somebody screwed up your system over there... –  Sep 20 '12 at 06:50
  • Thanks. I used the wrong search expression. Can you answer my question from my last commend? that would help me much. – Manfred Sep 20 '12 at 06:51
  • @Manfred why do you keep asking me to answer your last question? Didn't I just do that? You were asking about the missing librt.so file, right? –  Sep 20 '12 at 06:52
  • How did you found out that that one is missing and not libXY.so ? – Manfred Sep 20 '12 at 06:52
  • @Manfred did you read the question and answer I provided you the link with? –  Sep 20 '12 at 06:54
  • yes, but i didn't find a word about how to identify the .so file. Maybe I 'm too foolish or I didn't explained well what I looking for – Manfred Sep 20 '12 at 06:58
  • @Manfred When I googled the error you explained, the first hit was that question. In the answer it's clearly explained that one has to link against librt.so. What kind of further evidence do you expect? –  Sep 20 '12 at 07:00
  • Ah ok there is a misunderstanding. I thought there is a web side or a program or a list or what ever where you can look " aha time.h <-> librt.so" , but in this case there isn't something like that. Thanks and sorry for my harassment. – Manfred Sep 20 '12 at 07:05
  • @Manfred please update your question with these details and the down votes can be removed. – Steve-o Sep 20 '12 at 14:27
  • @Manfred the header files are not important, you should be concerned about the APIs you are using, thus you search for `clock_gettime` and from the [manual](http://www.kernel.org/doc/man-pages/online/pages/man2/clock_getres.2.html) it says use `-lrt`. – Steve-o Sep 20 '12 at 14:29