Create a Dynamic Library

Learn how to create a dynamic library.

In this and the next lesson, we demonstrate how to create and use a Dynamically Linked Library (DLL). For this, we would create the library and the client that uses the library. First, we would create the DLL.

Creating a dynamic library in Linux

Follow the steps shown below:

  1. In lib_dynamic.c, define the factorial( ) function.

  2. Once the header and the source file are created, click the RUN button; it will open the terminal for you and, then, you can execute the following commands in the given terminal:

  • gcc -Wall -fPIC -c lib_dynamic.c

  • gcc -shared -Wl,-soname,libdynamic.so -o libdynamic.so lib_dynamic.o

Get hands-on with 1200+ tech skills courses.