Position: Index > Unclassified >

Embedded C program libraries and linking

2017-12-21 10:42  
Declaration:We aim to transmit more information by carrying articles . We will delete it soon, if we are involved in the problems of article content ,copyright or other problems.

What is compilation of program maybe it is more or less clear. But what is program linking? I am sure many beginners heard of this but done exactly know what it is. In a few words I can say, that linker creates an output file from relocatable objects.

Compiler is not one big program. It usually consist of up to a dozen smaller programs. These programs are controlled by some program so called a€?program drivera€?. This driver can be a makefile and make.exe program. The pieces of whole compiler are: the preprocessor, the syntactic and semantic checker, code generator, the assembler, the optimizer, the linker and make program.

Lets see common example of compiling procedure:

embedded_compiler

These programs are split in pieces for easier design and maintain as each is specialized program in its own. In many cases same program can be used for different programming languages. One disadvantage of running different tools will take longer time that running one bigger program. Because there is need to send information between programs.

There can be two types of libraries that can be linked to program: static and dynamic. If a copy of libraries is physically part of executable, then we say program is statically linked. If executable contains filenames that enable loader to find references to library then we say program is dynamically linked. Dynamic linking is more part of operating systems like MS Windows. In Embedded systems usually there is static library linking, where libraries become part of program. This is why sometimes this is not good choice to use pre-built universal libraries.

static_vs_dynamic_linking

As you see dynamic library linking benefits are obvious. But for dynamic linking there should be at least some kind of operation system to have ability to store dynamic libraries. I am not sure about embedded RTOS if there is some dynamic linking supported a€“ maybe embedded linux I am not sure. But usually we do statical linking when using external libraries when developing embedded projects. Some libraries are rich in their functionalities that smaller microcontrollers arent capable to store all executable. For instance Procyon AVRlib has a bunch of pre-built libraries, but linking to them may take huge amounts of program memory that smaller AVR microcontrollers won’t handle. Sometimes it is better to write your own routines than link to existing ones where are many additional features and triggers includes.


Reprinted Url Of This Article:
http://www.scienceprog.com/embedded-c-program-libraries-and-linking/