-2

I would like to ask two questions.(Microcontroller Project)

  1. What is the difference between Runtime library and standard library (For c language)?
  2. I would like to write a code for microcontroller that will use standard c library. Previously I used to work in custom defined library environment. But now I have to integrate Standard C libraries. I am going to use Greenhills compiler. My questioins are: Do I have to integrate standard C library or Runtime library? how to get these libraries and integrate into the system?

Thank you

sepp2k
  • 363,768
  • 54
  • 674
  • 675
waq
  • 15
  • 6

1 Answers1

1
  1. What is the difference between Runtime library and standard library (For c language)?

The C standard library is a set of functions that every conforming hosted C implementation makes available to programs. In its case, "library" means an abstract collection of functions, not a linkable object file.

A runtime library, on the other hand, is a binary library file or files containing function implementations that the implementation wishes to provide to all programs. It is specific to a given C implementation. Runtime libraries typically contain implementations of at least some of the standard library functions, but they may omit some or even all of those, and they may include functions not specified to belong to the standard library.

Depending on the implementation, some or even all of the standard library functions, and perhaps even more functions, are made available to programs by default even when no libraries are specifically linked.

  1. I would like to write a code for microcontroller that will use standard c library. Previously I used to work in custom defined library environment. But now I have to integrate Standard C libraries. I am going to use Greenhills compiler. My questioins are: Do I have to integrate standard C library or Runtime library? how to get these libraries and integrate into the system?

If you're writing for a microcontroller then that's probably a standalone implementation, not a hosted one. Standalone implementations are not required to provide most standard library functions, which I guess is the point. In any event, standard library vs. runtime library is a red herring. What you need is implementations of the functions you actually use. In all likelihood, those form a smallish subset of the standard library functions, plus some of your functions.

As to where to get them, if Greenhills does not provide a version for you then there are lightweight implementations of the C standard library available, such as µClibc (== microcontroller libc). Google can probably help you find more. If you choose to integrate one of these then be sure to abide by its licensing terms. You may need your management to approve that.

John Bollinger
  • 160,171
  • 8
  • 81
  • 157
  • In this specific case, since it sounds like we're dealing with custom microcontrollers, "C runtime library" might refer very specifically to the C runtime itself. This is the software that is responsible for providing the C-style execution environment, as well as running any necessary code that needs to execute before and after the main() function, such as invoking program constructors. https://en.wikipedia.org/wiki/Crt0 – David Sep 14 '16 at 00:48
  • @John Bollinger Thank you for the detailed answer. It helped me alot. Like µClibc, I also found another library '' newlib''. Now both contain bunch of files. I do not know how to make runtime/standard library out of these files. I have in my mind that for library I jst have to copy ''.c'' & ''.h'' files into my environment. but there I do not find any these files. Thanks – waq Sep 14 '16 at 15:08
  • @waq, I'm sorry, but this is a question & answer site, not a professional development clinic. If you're really as lost as you seem to be, then you probably need some face-to-face assistance. A supervisor or a colleague would be would be a more appropriate resource for that. – John Bollinger Sep 14 '16 at 15:15
  • @waq Surely your Green Hills compiler came with an implementation of the standard libraries and run-time support libraries (mine did). Read the documentation. Or contact Green Hills Software for support. – kkrambo Sep 14 '16 at 16:22
  • @kkrambo In my environment of greenhills, I can see the header files for standard libraries. but I could not find the archive files ''.a''. or another files for standard libraries. – waq Sep 14 '16 at 20:57