Computer Science

Share this article:

Computer Science

  • Join our comunity:

C Libraries

By: , Posted on: July 19, 2017

Embedded Software The Works new cover

For a software developer, the idea of a library is quite simple: It is a file containing a (typically large) number of functions/procedures/subroutines in a special format. At link time, the linker looks in the library (or there may well be more than one, in which case it checks each in turn) to resolve any references to functions not satisfied by the supplied object modules. This means that the programmer just needs to reference commonly used functions and their code is pulled in automatically.

Of course, it is not quite that simple. Also, as with most aspects of embedded programming, libraries present more challenges and options to developers …

When developing software for the desktop, most programmers give little consideration to standard libraries, concentrating only on any special libraries that might be employed for their application. Such libraries are commonly dynamically linked, so they are quite different from anything used in most embedded systems.

C libraries

The fact that every embedded system is different is often cited (by me anyway) as a reason for much of the complexity with developing embedded software. The use of libraries reflects this. Apart from getting a library that is right for the target device family and the chosen compiler, there may be a wide selection of other variations: chip family member specifics, register relative addressing, PC relative (position independent) code, endianity, size/speed optimization, the list goes on …

A standard C library contains two types of functions:

  • Functions called by the generated code where the compiler has determined that so doing is preferable to creating inline instructions.
  • Functions explicitly called by the code (like printf()).

Commonly a single library is used to contain both these types of function. However, that is not always the case. For GNU compilers, one library (libgcc) contains the compiler support functions. There are a number of options to choose from for the explicitly called functions:

  • GLIBC is very full-featured and designed to be used with Linux, including not only the ISO C functions, but POSIX support and GNU extensions.
  • uClibc is also designed to be used with Linux (or uClinux) and contains a subset of GLIBC, so it has a smaller footprint.
  • Newlib is smaller still and is primarily aimed at embedded applications with no OS.

An interesting question is: what is the benefit of a smaller library, given that only called functions are extracted from it so final binary image size will not vary? I can think of about three answers:

  • A smaller library results in faster link time.
  • Less choice of functions might make a programmer more careful in their selection, thus resulting in more optimal (smaller) code.
  • A small library may also have smaller (less capable) versions of functions, which will result in a smaller application memory footprint.

Read more from Colin about embedded software on SciTech Connect


Colin’s most recent publication, Embedded Software: The Works is available now on the Elsevier Store and on ScienceDirectEmbedded Software The Works new cover

Save 30% on his book and other Newnes Press and embedded systems books. Use discount code “STC317″ at checkout. 

About the Author

Colin WallsColin Walls (@Colin_Walls) is an embedded software technologist at Mentor Graphics (@mentor_graphics), the leading EDA software company.

You can read more about Colin and his work on embedded systems at The Colin Walls Blog at Mentor Graphics here. Connect with Colin online here:

facebook google plus linkedin slideshare twitter wordpress

Connect with us on social media and stay up to date on new articles

Computer Science

Computing functionality is ubiquitous. Today this logic is built into almost any machine you can think of, from home electronics and appliances to motor vehicles, and it governs the infrastructures we depend on daily — telecommunication, public utilities, transportation. Maintaining it all and driving it forward are professionals and researchers in computer science, across disciplines including:

  • Computer Architecture and Computer Organization and Design
  • Data Management, Big Data, Data Warehousing, Data Mining, and Business Intelligence (BI)
  • Human Computer Interaction (HCI), User Experience (UX), User Interface (UI), Interaction Design and Usability
  • Artificial intelligence (AI)
Morgan Kaufmann companion resources can be found here You can also access companion materials and instructor’s resources for all our new books on the Elsevier Store. Search by author, title or ISBN, then look for the “Resources” tab on any book page. Looking for companion materials or instructor’s resources for these titles? Connect below:

Social Media Auto Publish Powered By : XYZScripts.com