C Programming

Listed below is all the post about compiling and running C program in different platform (Windows, Mac and Linux)


C Programming in Max OS X

C Programming in Linux Part 1
C Programming in Linux Part 2

Static Library and Dynamic Link Library

The purpose of creating software libraries is to collect all the customized functions you have created so that you could reuse those functions for other programs.

There are two types of libraries, they are the static library and dynamic link library.

What is Static Library?
Static library is a collection of your program functions that could be reuse for other programs. When you write a new program that contains the customized function from the static library, during compilation, the compiler will find the static library and copied the code of the customized function and incorporated in your program.

What is Dynamic Link Library?
Dynamic link library (DLL a.k.a. Shared Library in Linux) is a separate software library that contains customized function to be reuse by other program. The main difference between static and dynamic link library is that, the code will not be incorporated into the application software during compilation. Instead the library code will be loaded during program execution time.

There are two methods of using dynamic link library, you can use either implicit link or explicit link when using DLL. When using implicit link method, your program will call the external function as per normal. During program execution time, the dynamic linker will load the specific DLL file so that when you program call the function, the system will run the code in the DLL.

When using explicit link method, you need to programmatically find the external function, call and load the external function.

Listed below contains articles that demonstrate the use of static and dynamic link library. Please note that I did not include explicit link DLL because the usage is not common.

Windows (Visual Studio 2012)
Static Library
Create C Program with Static Library using Visual Studio 2012
Create C Program with Static Library using Command Line in Windows

Dynamic Library (Dynamic Link Library or DLL)
Create C Program with Dynamic Link Library (DLL) using Visual Studio 2012 (Implicit Link)
Create C Program with Dynamic Link Library (DLL) using Command Line (Implicit Link) in Windows

Linux
Static Library
Create C Program with Static Library in Linux

Dynamic Library (Shared Library)
Create C Program with Shared Library (Dynamic Link) in Linux


Mac OS X
Static Library
Create C Program with Static Library using Command Line in Mac OS X
Create C Program with Static Library using Xcode in Mac OS X

Dynamic Library
Create C Program with Dynamic Library using Command Line in Mac OS X
Create C Program with Dynamic Library using Xcode in Mac OS X



*****


Comments

Popular posts from this blog

Revive Old Mac Mini (2009) with Linux

Configure Unattended Upgrades on Raspberry Pi

Install and Configure RealVNC in Linux Ubuntu 18.04 LTS