473,494 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Way to view public function names in a library

Hi,

I got a C library, is there a way to view the public function names in
this library so that I can use in my C program?

Thanks.
Oct 9 '08 #1
16 3253
Xiaoxiao <xi**********@live.comwrites:
I got a C library, is there a way to view the public function names in
this library so that I can use in my C program?
There is no portable way to do that.

Your best bet is to read the documentation that (presumably)
accompanies the library. Just knowing the names of the functions
doesn't give you enough information.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Oct 9 '08 #2
Xiaoxiao <xi**********@live.comwrites:
Hi,

I got a C library, is there a way to view the public function names in
this library so that I can use in my C program?
This is technically off-topic, since it's not about the C language
itself but about whatever compiler and related tools you are using (you
didn't say what they are). You should probably look for another group
that is more specifically dedicated to your system and/or compiler.

However, on many systems the command that does this is called 'nm'.
Oct 9 '08 #3
On 9 Oct, 14:08, Keith Thompson <ks...@mib.orgwrote:
Xiaoxiao <xiaoxiaoy...@live.comwrites:
I got a C library, is there a way to view the public function names in
this library so that I can use in my C program?

There is no portable way to do that.

Your best bet is to read the documentation that (presumably)
accompanies the library. *Just knowing the names of the functions
doesn't give you enough information.

--
Keith Thompson (The_Other_Keith) ks...@mib.org *<http://www.ghoti.net/~kst>
Nokia
"We must do something. *This is something. *Therefore, we must do this."
* * -- Antony Jay and Jonathan Lynn, "Yes Minister"
Thanks Keith. My question should be how to know the function prototype
in the shared library. It seems from your answer that there is no way
to do it except getting the document, is that right?
Oct 9 '08 #4
On 9 Oct, 14:17, Nate Eldredge <n...@vulcan.lanwrote:
Xiaoxiao <xiaoxiaoy...@live.comwrites:
Hi,
I got a C library, is there a way to view the public function names in
this library so that I can use in my C program?

This is technically off-topic, since it's not about the C language
itself but about whatever compiler and related tools you are using (you
didn't say what they are). *You should probably look for another group
that is more specifically dedicated to your system and/or compiler.

However, on many systems the command that does this is called 'nm'.
Thanks Nate. I didn't know where to ask but because I will call it
from a C function if I can, so I posted the question here. I am going
to use gcc compiler in Linux to compile my C program. I will check
'nm' to see what does it do.
Oct 9 '08 #5
Xiaoxiao <xi**********@live.comwrites:
On 9 Oct, 14:08, Keith Thompson <ks...@mib.orgwrote:
>Xiaoxiao <xiaoxiaoy...@live.comwrites:
I got a C library, is there a way to view the public function names in
this library so that I can use in my C program?

There is no portable way to do that.

Your best bet is to read the documentation that (presumably)
accompanies the library. *Just knowing the names of the functions
doesn't give you enough information.

Thanks Keith. My question should be how to know the function prototype
in the shared library. It seems from your answer that there is no way
to do it except getting the document, is that right?
That's *probably* right. The format of a shared library, and even
what kind of information is stored in it, is beyond the scope of the C
langauge standard. Typically, though, I think all you could get from
a library is the name and entry point for each function (and the code
that implements each function). Prototypes are generally available in
header files. And if the header file is inconsistent with the
library, you're out of luck.

But even knowing the prototype for each function, though it might tell
you how to write a legal call to the function, isn't going to tell you
how to use it properly. An example from the standard library: knowing
that printf is declared as:

int printf(const char * restrict format, ...);

doesn't tell you what the format string should look like; only the
documentation can tell you that.

If you have a library and you want to call functions in that library,
reading the documentation seems like the obvious answer. The fact
that you're asking for another way to get information about the
functions in a library implies that you have another requirement that
you haven't told us about. If you'll tell us what you're really
trying to do, we may be able to help (or at least offer advice on
where you can find information relevant to your system).

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Oct 9 '08 #6
Xiaoxiao wrote, On 09/10/08 18:50:
Hi,

I got a C library, is there a way to view the public function names in
this library so that I can use in my C program?
The best method is to read the documentation. The second best method is
to read the header files provided with the library. If no documentation
or header files are provided then the next best method is to get them,
followed by using a different library.
--
Flash Gordon
If spamming me sent it to sm**@spam.causeway.com
If emailing me use my reply-to address
See the comp.lang.c Wiki hosted by me at http://clc-wiki.net/
Oct 9 '08 #7
On 9 Oct, 14:38, Keith Thompson <ks...@mib.orgwrote:
Xiaoxiao <xiaoxiaoy...@live.comwrites:
On 9 Oct, 14:08, Keith Thompson <ks...@mib.orgwrote:
Xiaoxiao <xiaoxiaoy...@live.comwrites:
I got a C library, is there a way to view the public function names in
this library so that I can use in my C program?
There is no portable way to do that.
Your best bet is to read the documentation that (presumably)
accompanies the library. *Just knowing the names of the functions
doesn't give you enough information.
Thanks Keith. My question should be how to know the function prototype
in the shared library. It seems from your answer that there is no way
to do it except getting the document, is that right?

That's *probably* right. *The format of a shared library, and even
what kind of information is stored in it, is beyond the scope of the C
langauge standard. *Typically, though, I think all you could get from
a library is the name and entry point for each function (and the code
that implements each function). *Prototypes are generally available in
header files. *And if the header file is inconsistent with the
library, you're out of luck.

But even knowing the prototype for each function, though it might tell
you how to write a legal call to the function, isn't going to tell you
how to use it properly. *An example from the standard library: knowing
that printf is declared as:

* * int printf(const char * restrict format, ...);

doesn't tell you what the format string should look like; only the
documentation can tell you that.

If you have a library and you want to call functions in that library,
reading the documentation seems like the obvious answer. *The fact
that you're asking for another way to get information about the
functions in a library implies that you have another requirement that
you haven't told us about. *If you'll tell us what you're really
trying to do, we may be able to help (or at least offer advice on
where you can find information relevant to your system).

--
Keith Thompson (The_Other_Keith) ks...@mib.org *<http://www.ghoti.net/~kst>
Nokia
"We must do something. *This is something. *Therefore, we must do this."
* * -- Antony Jay and Jonathan Lynn, "Yes Minister"
Thanks a lot for the help, Keith.
The fact that you're asking for another way to get information about the
functions in a library implies that you have another requirement that
you haven't told us about.
That's true. I got some C source code and shared library from
somewhere and studying it, and will modify it later, and I don't have
the document. I saw somewhere in the original C code that calls the
library functions that I don't know the function prototypes, so that's
why I was asking. Now after reading your post, I also see that there
are header files on the library there, then I can get the function
prototypes from the header files, as you have suggested. But there are
so many of them, and also as you said, even from the function
prototypes I will still need the document to use the functions
correctly.

I have one more question related to this: in generally, does every
shared memory go along with a header file or not? I mean, if I will
create a shared library for someone, do I also need to provide the
header file to him or not? I checked on the internet on the tutorials
of shared libary on Linux, and knew that there were static and dynamic
libraries, but all of them didn't mention whether header files are
needed to provide to others along with the produced libary. Or the
header file is just used for indicting the function prototypes in the
libary and doesn't really need for the application which calls the
library?

please forgive my entry level question.

Thank you so much for your patience and help again.
Oct 9 '08 #8
Xiaoxiao <xi**********@live.comwrites:
I have one more question related to this: in generally, does every
shared memory go along with a header file or not? I mean, if I will
create a shared library for someone, do I also need to provide the
header file to him or not?
Generally, he will need the header file if he wants to compile a program
that uses the library. If you give him a program that's already
compiled, together with the shared library, the header file is not needed.
Oct 9 '08 #9
On 9 Oct, 15:20, Nate Eldredge <n...@vulcan.lanwrote:
Xiaoxiao <xiaoxiaoy...@live.comwrites:
I have one more question related to this: in generally, does every
shared memory go along with a header file or not? I mean, if I will
create a shared library for someone, do I also need to provide the
header file to him or not?

Generally, he will need the header file if he wants to compile a program
that uses the library. *If you give him a program that's already
compiled, together with the shared library, the header file is not needed..
Thanks a lot for the clarification, Nate. Now I understand them much
better.
Oct 9 '08 #10
On 9 Oct 2008 at 18:17, Nate Eldredge wrote:
Xiaoxiao <xi**********@live.comwrites:
>I got a C library, is there a way to view the public function names
in this library so that I can use in my C program?

However, on many systems the command that does this is called 'nm'.
As "Keith Thomson" has pointed out (in an unusually helpful answer for
him, given that the subject is one that he mistakenly regards is "off
topic"), while nm will list the *names* of the symbols (like function
names) in an object file or library, it won't tell you the actual
prototype of a function - you need the header file for that.

You should also be aware that if the library has been stripped of
debugging symbols (this will usually be the case for release versions of
libraries), then nm won't be able to list the symbols because they'll no
longer be there.

Oct 9 '08 #11
Antoninus Twink <no****@nospam.invalidwrites:
On 9 Oct 2008 at 18:17, Nate Eldredge wrote:
>Xiaoxiao <xi**********@live.comwrites:
>>I got a C library, is there a way to view the public function names
in this library so that I can use in my C program?

However, on many systems the command that does this is called 'nm'.

As "Keith Thomson" has pointed out (in an unusually helpful answer for
him, given that the subject is one that he mistakenly regards is "off
topic"), while nm will list the *names* of the symbols (like function
names) in an object file or library, it won't tell you the actual
prototype of a function - you need the header file for that.
True.
You should also be aware that if the library has been stripped of
debugging symbols (this will usually be the case for release versions of
libraries), then nm won't be able to list the symbols because they'll no
longer be there.
That's not correct. *Debugging* symbols may be missing, but what's
needed here are the symbols for the library's functions and variables
themselves. These must be present, because otherwise it would be
impossible to link against the library.

In the case of a shared library, some versions of nm don't show dynamic
symbols by default, so it may appear that there are no symbols. My
version of nm uses the -D option to show dynamic symbols, which would
still be present.

You are probably thinking of binaries (executables), which often are
distributed entirely stripped of symbols, as they're no longer needed.
Oct 9 '08 #12
Xiaoxiao wrote:
>
I got a C library, is there a way to view the public function
names in this library so that I can use in my C program?
I suggest reading the documentation.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
Oct 10 '08 #13
On 9 Oct, 20:24, CBFalconer <cbfalco...@yahoo.comwrote:
Xiaoxiao wrote:
I got a C library, is there a way to view the public function
names in this library so that I can use in my C program?

I suggest reading the documentation.

--
*[mail]: Chuck F (cbfalconer at maineline dot net)
*[page]: <http://cbfalconer.home.att.net>
* * * * * * Try the download section.
Thanks a lot for more help again. I really appreciate the Internet and
everyone's unselfish help. When I know something in the future, I will
also try to help people on their questions.
Oct 10 '08 #14
On 10 Oct 2008 at 17:20, Xiaoxiao wrote:
On 9 Oct, 20:24, CBFalconer <cbfalco...@yahoo.comwrote:
>I suggest reading the documentation.

Thanks a lot for more help again. I really appreciate the Internet and
everyone's unselfish help.
Yep - help like that provided by CBF above you won't get anywhere except
on the internet...

Oct 10 '08 #15
Xiaoxiao wrote:
CBFalconer <cbfalco...@yahoo.comwrote:
>Xiaoxiao wrote:
>>I got a C library, is there a way to view the public function
names in this library so that I can use in my C program?

I suggest reading the documentation.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.

Thanks a lot for more help again. I really appreciate the Internet
and everyone's unselfish help. When I know something in the future,
I will also try to help people on their questions.
Bad idea. If you send them to a suitable newsgroup, you can answer
their question there. You will have some assurance that erroneous
answers will be corrected by other users. This (correction) does
not necessarily apply without picking the correct group.

Also, please always delete the signature from any quotation in your
reply. The signature is everything following the '-- ' sig marker
(inclusive).

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
Oct 10 '08 #16
On 10 Oct 2008 at 22:34, CBFalconer wrote:
Xiaoxiao wrote:
>When I know something in the future, I will also try to help people
on their questions.

Bad idea.
All you need to know about CBF in two words.

Oct 10 '08 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1681
by: Booted Cat | last post by:
I've seen lots of discussions on the proposed inclusion of "function call with named arguments" to C/C++ on these newsgroups. My proposal is slightly different in that: * No ANSI approval is...
8
2226
by: Alvo von Cossel I | last post by:
hey everybody, I have written a great browser but it is missing a feature (quite a lot actually, but forget about them for now). that feature just so happens to be the View > Source function....
2
3360
by: Senapathy | last post by:
VC++ .NET 2003 Standard Edition Win XP, SP2 Hi, I have a code that builds under VC6.0, but fails to link in VC7.1. The offending code is as follows: _AFX_RICHEDIT_STATE* const pEditState...
12
2192
by: Raed Sawalha | last post by:
I have the following table which i can not switcha to design view error message said Could not open in Design view. Quote values differently inside a '<% ...."value"... %>' block. and the...
10
8769
by: Zack Sessions | last post by:
Has anyone tried to create a SQL7 view using the CREATE VIEW command and ADO.NET? If so, is there a trick in trapping a SQL error when trying to create the view? I have a VB.NET app that, amoung...
1
3564
by: Director - Minvent | last post by:
Hi, I am trying to work out the easiest way to add some things to a treeview. I have got a list of the priviliged names for each of the computers e.g. ...
0
2379
by: weiwei | last post by:
Hi; I am having trouble to get variable from grid view. here is my scenario. I want to delete a row in database from web page, in additon, I also want to delete that user's directory in c:drive. ...
0
2385
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
0
1369
by: Christian | last post by:
Hi all, i already posted this in dotnet.vb.controls but i need some help, so i cant wait... I have written a web control library and have some problems with it. The Library contains only two...
0
7119
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7367
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.