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.
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.
我还建议阅读著名的Drepper论文: 如何编写共享库 。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.