This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Linux Shared Libraries - How to create?


On Dec  6, 1999, Marcos Barreto de Castro <mbdecastro@yahoo.com> wrote:

>    Which are the steps I need to perform in order to
> create a shared library under Linux?

Compile the source files with `gcc -c -fPIC', then link them with `gcc
-shared'.  Or you may want to try GNU libtool.

>    After I create it, how can I compile and link a
> program to use the shared library just created?

If the library name is libfoo.so, just link the program with -lfoo or
libfoo.so.  You may have to specify -L/pathname for the library to be
found.

> Do I have to mention the library in the Makefile?

You don't really need a Makefile.  If you want to use one, you may
want to take a look at GNU automake, that is well integrated with
libtool and makes the creation of shared libraries quite easy.

>    Could anyone provide me with examples of the whole
> process?

The libtool manual is full of such examples.

-- 
Alexandre Oliva http://www.ic.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
oliva@{lsd.ic.unicamp.br,guarana.{org,com}} aoliva@{acm,computer}.org
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
** I may forward mail about projects to mailing lists; please use them


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]