LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 06-05-2007, 04:42 AM   #1
letuanle
LQ Newbie
 
Registered: Jul 2006
Posts: 2

Rep: Reputation: 0
How to know the library name when I already know function name


Dear all,

When I call a function in linux kernel, I want to know what library name contains that function. Please give me the solution.

For example, I want to know the name of library which contains local_bh_enable()

Thank you
Tuan Le

Last edited by letuanle; 06-05-2007 at 04:52 AM.
 
Old 06-06-2007, 01:21 PM   #2
Centinul
Member
 
Registered: Jun 2005
Distribution: Gentoo
Posts: 552

Rep: Reputation: 30
Function: Google
Input: local_bh_enable()
Output: asm/smp.h

In all seriousness, I don't know how you would try and use a function (assuming C) in C without knowing the library you are calling it from. If you don't include the library than you can't call the function.

Do you think you could explain a little more clearly what you are trying to do?

Thanks
 
Old 06-06-2007, 10:08 PM   #3
letuanle
LQ Newbie
 
Registered: Jul 2006
Posts: 2

Original Poster
Rep: Reputation: 0
Hello Centinul,

It is easy to know which .h file need to include into my source code which calling the local_bh_enable() function. But when I compile, the error occurs (cannot link the library). I need to know the name of library which contains local_bh_enable() to pass to the command line

gcc myproject -lXX

My question is XX = ?

(XX is the name of library which contains local_bh_enable())


Thank you

Tuan Le
 
Old 06-07-2007, 12:03 AM   #4
The_Nerd
Member
 
Registered: Aug 2002
Distribution: Debian
Posts: 540

Rep: Reputation: 32
Do a google search: http://www.google.com/search?client=...utf-8&oe=utf-8
 
Old 06-07-2007, 11:32 PM   #5
kaz2100
Senior Member
 
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy jessie
Posts: 1,399

Rep: Reputation: 81
Hya,

I had same question a while ago. I did not know the answer. So that, I used "nm" to see. But it did not work on Penguin. It worked with Macintosh.

Also it was not efficient at all....


Happy Penguins!
 
Old 06-08-2007, 01:51 AM   #6
haxpor
Member
 
Registered: Dec 2006
Distribution: Ubuntu 9.10
Posts: 86

Rep: Reputation: 15
The library contains in Linux is in Binary Code, so we cannot search it like the header file, I guess the only way we can do is search through the internet.

Any better ideas?
 
Old 06-08-2007, 06:11 AM   #7
makyo
Member
 
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 718

Rep: Reputation: 72
Hi.
Quote:
Originally Posted by kaz2100
I had same question a while ago. I did not know the answer. So that, I used "nm" to see. But it did not work on Penguin. It worked with Macintosh.

Also it was not efficient at all....
My experience is different from this. The utility nm has worked on every *nix system I have used. I don't know what Penguin is, however.

What do you mean by not efficient at all? ... cheers, makyo
 
Old 06-08-2007, 08:06 AM   #8
kaz2100
Senior Member
 
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy jessie
Posts: 1,399

Rep: Reputation: 81
Hya,

My Penguin is etch Debian. 2.6.20.11

Code:
>nm /lib/libm-2.3.6.so
nm: /lib/libm-2.3.6.so: no symbols
It is quite inefficient. Follow links to real one (/usr/lib/libm.so -> /lib/libm.so -> lib/libm-2.3.6.so) on every individual library until I find.
 
Old 06-08-2007, 08:53 AM   #9
makyo
Member
 
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 718

Rep: Reputation: 72
Hi.
Quote:
-D
--dynamic
Display the dynamic symbols rather than the normal symbols. This
is only meaningful for dynamic objects, such as certain types of
shared libraries.

-- excerpt from man nm
For example:
Code:
#!/bin/sh

# @(#) s1       Demonstrate nm extraction of symbols from shared libraries.

set -o nounset
echo " sh version: $BASH_VERSION"

LIB=/usr/lib/libm.a
echo
echo " Looking at $LIB:"
nm $LIB 2>/dev/null | head -10

LIB=/lib/libm-2.3.2.so
echo
echo " Looking at $LIB:"
nm -D $LIB 2>/dev/null | head -10

exit 1
Which produces:
Code:
% ./s1
 sh version: 2.05b.0(1)-release

 Looking at /usr/lib/libm.a:

k_standard.o:
         U _LIB_VERSION
         U __assert_fail
         U __copysign
         U __errno_location
00000000 T __kernel_standard
         U __rint
         U fputs
         U fwrite

 Looking at /lib/libm-2.3.2.so:
00000000 A GLIBC_2.0
00000000 A GLIBC_2.1
00000000 A GLIBC_2.2
         w _Jv_RegisterClasses
00021538 D _LIB_VERSION
         U __assert_fail
0000c380 T __clog10
00013090 T __clog10f
0001a7b0 T __clog10l
         w __cxa_finalize
If I understand your comment regarding the inefficiency of following links, that seems to be an issue of the design of library layout, rather than nm. Please clarify if I have not understood correctly ... cheers, makyo
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
list library function of a shared library .so powah Linux - General 7 10-25-2011 04:47 AM
gets library function in C reddazz Programming 3 03-27-2005 02:04 AM
Source Function Library dadepfan Linux - General 2 08-22-2004 11:06 PM
what is the function library of the basic graphics library in rethat9.0? zerwolve Red Hat 0 04-29-2004 09:18 PM
C# using DotGNU, how do I use a library function? exodist Programming 3 02-22-2004 09:41 PM


All times are GMT -5. The time now is 03:17 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration