![]() |
| | #1 |
| Devil™ Join Date: Oct 2007 Location: IIT-Kharagpur, India
Posts: 104
| how to know which function belongs to which library? what is the best way to know which function call belongs to which library? I was coding in C and using GCC 4.x.. I know how to use System V IPC semaphores.. but I wanted to learn POSIX semaphores.. so i went through some internet tutorials and from manpages I could learn.. but I have no idea which library to link with my object file, for my code to run.. I searched and searched.. after a long time I found it.. its like '-lrt'.. (no tute specified which lib to link )so my question is in general how can one find the library to reference? if I am stuck at such point.. man pages dont tell me which lib does this belong to.. they only tell me the header files.. I found some thread 2 years old on a forum asking to grep on /usr/lib/* I did it and ended up with lot many results saying few matches found.. and one of them is libgc.. I didnt understand why I should be linking if its in libgc.. Also that grep didnt list 'librt' ![]() can anyone help me?
__________________ C's Motto: who cares what it means? I just compile it!! |
| gibsosmat is offline | |
| | #2 |
| Registered User Join Date: Oct 2001
Posts: 2,110
| it's in man pthreads. it's -lpthread. |
| robwhit is offline | |
| | #3 |
| Devil™ Join Date: Oct 2007 Location: IIT-Kharagpur, India
Posts: 104
| thanks.. I thought it was only a posix thread lib.. ![]() still which is the actual lib for posix IPC functions? do you have any idea about my original prob?
__________________ C's Motto: who cares what it means? I just compile it!! |
| gibsosmat is offline | |
| | #4 |
| Registered User Join Date: Oct 2001
Posts: 2,110
| |
| robwhit is offline | |
| | #5 | |
| Protocol Test Engineer Join Date: Sep 2005 Location: fseek(UK)
Posts: 1,324
| Quote:
ssharish | |
| ssharish2005 is offline | |
| | #6 | |
| Devil™ Join Date: Oct 2007 Location: IIT-Kharagpur, India
Posts: 104
| Quote:
thats what I was doing ![]() but I tried something like -lpsem -lposix -lps -lsem -lsema -lsemaphores -lmut -lmutex etc but the actual name was -lrt.. I have no clue why it is so.. may be it is meant for ppl who know which lib are you going to use and not which header followed by lib.. ![]() still there might be some elegant way to find it out.. else google is for free .. or Brows LSB..
__________________ C's Motto: who cares what it means? I just compile it!! | |
| gibsosmat is offline | |
| | #7 | |
| Devil™ Join Date: Oct 2007 Location: IIT-Kharagpur, India
Posts: 104
| Quote: I found on some mailing lists that -lrt got some problem with pthread.. (it was 3-4 years old message) and was advised to used pthread for semaphores.. and after that found some proff's homepage yelling in red color to compile it with -lrt
__________________ C's Motto: who cares what it means? I just compile it!! | |
| gibsosmat is offline | |
| | #8 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,680
| If you just do a 'grep' on libraries, you find where the symbols are unresolved as well as defined. If you want to find where a symbol is defined, then use this approach, then pipe through grep Code: $ nm --defined-only /usr/lib/lib*.a | more /usr/lib/libautomode.a: automode.o: 00000000 b .bss 00000000 d .data 00000000 r .rdata 00000000 t .text 00000000 T _cygwin_premain0 00000000 d pf.0 /usr/lib/libbfd.a: archive.o: 00000000 b .bss 00000000 d .data 00000000 r .rdata 00000000 t .text 000000a8 r __PRETTY_FUNCTION__.0 000001e0 T __bfd_add_bfd_to_archive_cache 00000000 T __bfd_ar_spacepad |
| Salem is offline | |
| | #9 | |
| Devil™ Join Date: Oct 2007 Location: IIT-Kharagpur, India
Posts: 104
| Quote:
__________________ C's Motto: who cares what it means? I just compile it!! | |
| gibsosmat is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Undefined Reference Compiling Error | AlakaAlaki | C++ Programming | 1 | 06-27-2008 11:45 AM |
| How to fix misaligned assignment statements in the source code? | biggyK | C++ Programming | 28 | 07-16-2006 11:35 PM |
| c++ linking problem for x11 | kron | Linux Programming | 1 | 11-19-2004 10:18 AM |
| I need help with passing pointers in function calls | vien_mti | C Programming | 3 | 04-24-2002 10:00 AM |
| qt help | Unregistered | Linux Programming | 1 | 04-20-2002 09:51 AM |