Sunday, May 10, 2009

Libraries for C?

Can anyone explain or give a site about how to make c libraries step by step. The teacher gave no instruction and our book does not cover it. Thank you

Libraries for C?
The way you make libraries depends on the C compiler you're using.





Since you didn't mention your compiler I can only give you the concept.





First you need one or more header files with all external variables and functions of your library.





Then you need .c files that implement the functions. Private functions and global variables you don't need outside of the library you should mark as "static".





Then you invoke the C compiler with the "compile only" option .


"cc -c myfile.c" on Unix. this will give you a .o file under Unix or a .obj under Windos.





These .o resp. .obj files can be merged into a library.


On a Unix box you use the "ar" program, don't know what it's called on windows.
Reply:C Libraries are simply compiled programs that can be linked using a compiler to your current application. This is done, typically, for classes that you'd be using over and over (for example maybe a StringTokenizer). This allows for re-use of code.





This site can tell you how to compile your files into an archive file for library use.


http://publib.boulder.ibm.com/infocenter...
Reply:Well it is obvious the teacher wanted you to think about it. and obviously she has been talking on what sort of library .





This is one example





You know what files are and folders you can make a library out of them first folder name it library, then do AZ with folders inside,


No comments:

Post a Comment