?
Solved

c header files

Posted on 2003-02-18
2
Medium Priority
?
178 Views
Last Modified: 2010-04-17
C header files contain only function prototypes,right! Where are those functions stored?I means functions like printf and everything else?Are they stored in the C library?In those lib files?And what are those .so and .a files that you see there in the libraries, are they the functions that have already been compiled and made into objects?
0
Comment
Question by:vikasgkutty
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Expert Comment

by:TheBeaver
ID: 7979353
Basically, you have answered the last question yourself: The functions are compiled into the lib files.
The .a files are archives ie Multiple .obj files merged into one file for sanity preservation.

Note:Not all functions have source/object code! You see, C is made up of 27 standard commands (if, else, while, etc) these are interpreted by the compiler directly.
0
 
LVL 8

Accepted Solution

by:
ssnkumar earned 150 total points
ID: 7980516
Header file contains declarations; Library contains definitions.
stdio.h contains declaration for printf().
libc.so contains the definition of printf().

There are 2 types of library files. Static library, also called as archives and they contain .a extension. And dynamic library, also called as static object and they contain extension .so.

When you compile your C program, the compiler automatically links to few library and one of them is libc.so. For other libraries such as pthread or ncurses, you will have to link them while compiling.

The compiler first looks for static object and if it is not found, then it looks for archive.

The program compiled with archive will be huge, because the library will be compiled along with the program. The program compiled with static object will be small. They will contain, just the library name and path and the actual library file will be brought to memory during runtime. And if already some program which was using that library and hence the library file was already in memory, then the same copy will be shared by both, thus saving memory.

Hope this much info is enough:-) Tell me what else you want to know!?

-Narendra
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question