Where is the official "how to" about creating and understanding technics used in dynamic library. I'm using g++ compiler. I've googled this question but I can't find anything official about this.
Asked
Active
Viewed 7,049 times
2
-
Second result of google search with "create shared library" gave me [this.](http://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html) – wavemode Apr 21 '14 at 04:03
-
have you googled this one http://stackoverflow.com/questions/22001017/how-to-create-a-dynamic-library-for-c-on-linux?rq=1 ? – Jayesh Bhoi Apr 21 '14 at 04:07
-
Please see **[3.4. Creating a Shared Library](http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html)** in the `Shared Libraries` section of the Linux documentation project. – mockinterface Apr 21 '14 at 04:10
2 Answers
4
you can create shared library easily for example..
i have sample program for multiplication like multiplyNum.cpp
The -fpic option tells g++ to create position independent code which is needed for shared libraries. my source file reside in src/
folder.
> g++ -I ./inc -fpic -c src/multiplyNum.cpp -o obj/multiplyNum.o
Finally the shared library is created. Note the library name must start with the three letters lib and have the suffix .so.
> g++ -shared -o lib/libmultiplyNum.so obj/multiplyNum.o
You can use now libmultiplyNum.so
library in your makefile.

Jayesh Bhoi
- 24,694
- 15
- 58
- 73
1
I also recommend reading the famous Drepper's paper: How To Write Shared Libraries.

Basile Starynkevitch
- 223,805
- 18
- 296
- 547