[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: To compile a .so lib
On Fri, Feb 25, 2000 at 11:39:48PM +0530, Binand Raj S. wrote:
> Arun Sharma forced the electrons to say:
> > On Fri, Feb 25, 2000 at 06:18:26PM +0530, G Gautam wrote:
> > > I have the source for openssl, but when I compile, I get an .a archive.
> > > Lynx wants a .so library. How do I compile, so that I get a .so library ?
> > gcc -shared *.o -o libfoo.so
> Shouldn't that be:
> gcc -shared -Wl,-soname,libfoo.so -o libfoo.so *.o
> Arun? Isn't that -W necessary?
If you want to get the ELF major/minor version numbers right. The correct
linker line is:
gcc -shared -Wl,-soname,libfoo.so.M -o libfoo.so.M.m *.o
Where M = major version of libfoo.so and m = minor version. Further you
link apps with libfoo.so using:
gcc *.o -o app -lfoo
When you do that, you can use a new minor version of libfoo.so, without
relinking your app and not break binary compatibility.
The following URL explains the rationale and the nuts and bolts.
The FreeBSD handbook lists this as a requirement, but doesn't explain
http://www.freebsd.org/handbook/porting.html, section 126.96.36.199.
For more research - look for DT_SONAME in the ELF specification.