[96413] in RedHat Linux List

home help back first fref pref prev next nref lref last post

Re: how to compile a library ?

daemon@ATHENA.MIT.EDU (Emmanuel Papirakis)
Mon Oct 26 23:28:11 1998

From: "Emmanuel Papirakis" <epapirakis@hotmail.com>
To: redhat-list@redhat.com
Date: Mon, 26 Oct 1998 20:27:05 PST
Resent-From: redhat-list@redhat.com
Reply-To: redhat-list@redhat.com

>given some code, how do I compile it as a dynamically linkable shared 

	Hey,

There are two howtos on the subject. The gcc howto and the elf howto. 
Let's say that I have a file called papi.c and I want to make the linked 
object libpapi.so (all dynamic libraries in unix follw the format 
lib*.so).

I just do:

gcc -fPIC papi.c (and a list of other programs that go in the librarie)
gcc -shared -Wl,-soname,libpapi.so.1 -o libpapi.so.1.0 *.o

	Then I make a sym-link with the following command:

ln -s libpapi.so.1.0 libpapi.so.1
ln -s libpapi.so.1 libpapi.so

	This is good for maintanance pusposes (read the howto's for more info).

	Then, either move the files created in /lib, /usr/lib or something in 
/etc/ld.so.conf. Or add a directory you would like your librarie to be 
in in /etc/ld.so.conf and run ldconfig.

	You could also just set the LD_LIBRARY_PATH variable to the value of 
the directory you want them in. Finaly, to link a program with this 
library, run:

gcc [a bunch of flags] yourprogram.c -lpapi


				Papi



______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
		http://www.redhat.com http://archive.redhat.com
         To unsubscribe: mail redhat-list-request@redhat.com with 
                       "unsubscribe" as the Subject.


home help back first fref pref prev next nref lref last post