[LCP]creation of a shared library from a static library.

Andrew Weaver Andrew.Weaver at tecnomen.fi
Mon Nov 19 19:56:29 UTC 2001


Hmmm doesn't seem so does it?

gcc -shared -Wl,-soname,libmystuff.so.1 -o libmystuff.so.1.0.1 a.o b.o -lc

should do it for you as should gcc -L . cli.c -lmystuff -ladd


> -----Original Message-----
> From:	sasidhar p [SMTP:psasidhar at hotmail.com]
> Sent:	Monday, November 19, 2001 8:33 AM
> To:	linuxcprogramming at lists.linux.org.au
> Subject:	[LCP]creation of a shared library from a static library.
> 
> Hi,
> Can you create a shared library from a static library?
> I am facing some problems, can you please spare some time for me?
> 
> 1. I have 3 files a.c b.c and cli.c
> 2. i used the following steps
> 
> $ gcc -fPIC -g -c -Wall a.c
> $ ar rcs libadd.a a.o
> $ gcc -fPIC -g -c -Wall b.c
> $ gcc -shared -Wl,-soname,libmystuff.so.1 -o libmystuff.so.1.0.1 libadd.a 
> b.o -lc
> $ LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH ; export LD_LIBRARY_PATH
> $ ln -s libmystuff.so.1.0.1 libmystuff.so
> $ ls
> a.c a.o b.c b.o cli.c libadd.a libmystuff.so libmystuff.so.1.0.1 myhdr.h
> $ gcc -L . cli.c -lmystuff
> 
> This giving me the following error...
> 
> /tmp/ccbpNOID.o: In function `main':
> /tmp/ccbpNOID.o(.text+0x1d): undefined reference to `add'
> collect2: ld returned 1 exit status
> 
> 'add' is defined in a.c that is the static library...
> 
> thanx,
> Sasi.
> 
> 
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
> 
> _______________________________________________
> This is the Linux C Programming List
> :  http://lists.linux.org.au/listinfo/linuxcprogramming List



More information about the linuxCprogramming mailing list