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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
06-05-2007, 04:42 AM
|
#1
|
|
LQ Newbie
Registered: Jul 2006
Posts: 2
Rep:
|
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.
|
|
|
|
06-06-2007, 01:21 PM
|
#2
|
|
Member
Registered: Jun 2005
Distribution: Gentoo
Posts: 552
Rep:
|
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
|
|
|
|
06-06-2007, 10:08 PM
|
#3
|
|
LQ Newbie
Registered: Jul 2006
Posts: 2
Original Poster
Rep:
|
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
|
|
|
|
06-07-2007, 12:03 AM
|
#4
|
|
Member
Registered: Aug 2002
Distribution: Debian
Posts: 540
Rep:
|
|
|
|
|
06-07-2007, 11:32 PM
|
#5
|
|
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,333
Rep:
|
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!
|
|
|
|
06-08-2007, 01:51 AM
|
#6
|
|
Member
Registered: Dec 2006
Distribution: Ubuntu 9.10
Posts: 86
Rep:
|
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?
|
|
|
|
06-08-2007, 06:11 AM
|
#7
|
|
Member
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 713
Rep:
|
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
|
|
|
|
06-08-2007, 08:06 AM
|
#8
|
|
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,333
Rep:
|
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.
|
|
|
|
06-08-2007, 08:53 AM
|
#9
|
|
Member
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 713
Rep:
|
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
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 11:58 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|