From the course: Exploring C Libraries

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Writing your own library

Writing your own library - C Tutorial

From the course: Exploring C Libraries

Start my 1-month free trial

Writing your own library

- [Instructor] If you can code your own programs, you can write your own C libraries. Its not that difficult providing that you know a few incantations in these steps. Number one, write one or more source code files for the functions you need. Two, compile the source code into object code, and three, create an archive of the object code file. The archive becomes the library which you can then link into other programs as you see fit. Now, when you write the source code, you don't need a main function. Just write the functions to include in the library. Create a header file for the library, one that prototypes the functions, declares constants, type defs, and so on, and to compile the source code in the object code without creating a program, you add the dash little c compiler switch. To create the archive, you use the command line utility ar. Follow ar with the switches rcs and then the name of the library in the format…

Contents