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.
Clone this repository
git clone https://github.com/bobbyg603/linux-shared-libraryBuild the library as a .o file:
gcc -c -fpic -o mars.o mars.cppUse the .o file to create the shared library .so file:
gcc -shared -o libmars.o mars.oCompile the main program and link with the shared library:
gcc -L./ -Wl,-rpath=./ main.cpp -lmarsRun 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!