How to make your own dynamic connection library under Linux

xiaoxiao2021-03-06  97

Produce your own sharing library:

a.c

#include

Void PLN (Char * STR)

{

Printf ("% S / N", STR);

}

gcc -shared -fpic a.c -o libmy.so

-shared

Compile to create a shared library.

-fpic

Do some optimization when compiling shared libraries.

B.C

Extern Viod Pln (char *)

Main ()

{

PLN ("Hello World");

}

GCC B.c -Lmy

Note: By default, GCC is only looking for libraries only in the directory specified in /etc/ld.so.conf. (This should be added to the road)

-IDIR

It is also looking for header files under DIR.

-Ldir

Logo files are also logged under DIR.

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

New Post(0)