Compiling dynamic library

xiaoxiao2021-03-06  145

First, there is a need to generate a position-independent code. To do this, GCC needs to add compilation options -fpic gcc -fpic -o -c libbar.c

At this time, it is suitable for constructing shared libraries, plus -shared compile option gcc -shared -o libbar.so libbar.o can add a number of relocation files to the shared library. To connect the Baz.o and shared libraries, you can do this: # gcc -o -c baz.c # gcc -o baz baz.o -l. -Lbar

转载请注明原文地址:https://www.9cbs.com/read-127664.html

New Post(0)