Skip to content

bobbyg603/linux-shared-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to Build a Linux Shared Library

Harness the power of modular C++ and open-source

This is a companion repo for the article How to Build a Linux Shared Library published by Better Programming on Medium.

Getting Started

Clone this repository

git clone https://github.com/bobbyg603/linux-shared-library

Build the library as a .o file:

gcc -c -fpic -o mars.o mars.cpp

Use the .o file to create the shared library .so file:

gcc -shared -o libmars.o mars.o

Compile the main program and link with the shared library:

gcc -L./ -Wl,-rpath=./ main.cpp -lmars

Run the compiled program!

bobby@V:~/Desktop/linux-shared-library$ ./a.out 
Hello Earth!
Hello Mars!

If you found this tutorial useful please subscribe to @bobbyg603 on Medium. Thanks!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published