Static vs Dynamic libraries.

library1.cint sum (int a, int b)
return a+b;
int sub (int a, int b)
return a-b;
library1.h#ifndef _LIBRARY_1_H
#define _LIBRARY_1_H
int sum (int a, int b);
int sub (int a, int b);
The Uruguay’s Congress library. Totally unrelated to this article subject but it looks cool.

Creating static libraries using GNU.

#include <stdio.h> 
void fun(void)
printf("fun() called from a static library");
#ifndef LIB_MYLIB_H
void fun(void);#endif
gcc -c lib_mylib.c -o lib_mylib.o
ar rcs lib_mylib.a lib_mylib.o
#include "lib_mylib.h"void main(){
gcc -c driver.c -o driver.o
gcc -o driver driver.o -L. -l_mylib
fun() called from a static library

Creating dynamic libraries using GNU.

gcc *.c -c -fPIC
gcc *.o -shared -o
$ nm -D
0000000000000b1c T _abs
0000000000000b4f T _atoi
0000000000202048 B __bss_start
w __cxa_finalize
0000000000202048 D _edata
0000000000202050 B _end
0000000000000bf4 T _fini
w __gmon_start__
0000000000000910 T _init
0000000000000b13 T _isalpha
0000000000000b2e T _isdigit
0000000000000b0a T _islower
0000000000000b25 T _isupper
w _ITM_deregisterTMCloneTable
w _ITM_registerTMCloneTable
w _Jv_RegisterClasses
0000000000000a75 T main
0000000000000ba9 T _memcpy
0000000000000b97 T _memset
U printf
0000000000000ae0 T _putchar
0000000000000b37 T _puts
0000000000000b59 T _strcat
0000000000000bba T _strchr
0000000000000b89 T _strcmp
0000000000000b41 T _strcpy
0000000000000a9f T _strlen
0000000000000b67 T _strncat
0000000000000b78 T _strncpy
0000000000000bd7 T _strpbrk
0000000000000bc9 T _strspn
0000000000000be5 T _strstr
U write
$ ldd len => (0x00007ffd391b8000) => /home/vagrant/holbertonschool-low_level_programming/0x18-dynamic_libraries/ (0x00007f91da758000) => /lib/x86_64-linux-gnu/ (0x00007f91da388000)
/lib64/ (0x00007f91da960000)




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Building High Jump Facilities in Pickhill #High #Jump #Facility #Construction #Pickhill

A simple way to monitor and restart services using Monit

Generics in Java — Have no fear, Generics is here

[CheatEngine - C#] MegamanX4

Python Inheritance Types Illustrated with Code

Numpy cheat-sheet for basic MATH and STATS

Why Product Managers (& Marketers) Should Learn to Code

SQLite or Realm: What is the Top Choice for Android App?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Flavio Orlando

Flavio Orlando

More from Medium

Spring statement fails the fairness test

Factory Method Design Pattern

How to upload a Image to Amazon S3 using Swift