Normally when you code you will use a standard set of commands which have already been written for you. These are known as API calls (Application protocol interface). For example you may use a API in Java to create a user interface. The API's will have been written in the language themselves. When you make a call to an API that code will need to be included into the final compiled program.

Normally the code for API's is already compiled. As such you will not have access to the original source code. As it is already compiled it can not be included as part of the normal compile stage. When you have compiled your program you will have the situation below.

The API's code will be stored in library files. These libraries will then be linked to your code. This is done in the linking stage of the compiler. Linking basically tells your code how to access the library files. As the library files will be separate (for example as a dynamic link library in windows) the linker will generate code to allow the API calls to function correctly.

Linking is done in two ways. Firstly the library may be incorporated into the executable. Advantages of this is that you do not have to rely on the library being available on the machine for the code to work. Disadvantages are that it will increase the file size dramatically and also will not take into consideration any updates to the libraries used. The second way is to just create a link and keep the files separate. This is the most common way and allows file sizes to remain small. It also allows the code to take advantage of nay upgrades to library files which may of occurred. For example bug fixes. The biggest disadvantage to this is that the library must be available on the target computer. This is why a lot of software installers will attempt to install library files when they install the main software. The bigger the software the greater the chance it will be dependant on a lot of library files. A common problem in the early days of windows was that software did not install dependant libraries and put the ownership onto the user to install the libraries. Normally the error messages were very cryptic and left the user with little interaction of what they needed to do.

Dynamic libraries are loaded by a small utility known as a loader. The role of a loader is simply to load a library on request. If a library does not exist at run time then a run time error will be generated. These are very common (and annoying) on the linux operating system.

Commonly used libraries, such as Direct X, are now installed as part of the operating system. However this was not always the case. And certainly the user must manually install updates to direct X. Thankfully most game manufacturers for PC's check the direct X version and will install it if necessary.