1830908 Members
1776 Online
110017 Solutions
New Discussion

Re: Libraries

 
John Ramsay_2
Regular Advisor

Libraries

How do I make a set of libraries shared that were not originally not configured as shared?
4 REPLIES 4
A. Clay Stephenson
Acclaimed Contributor

Re: Libraries

You need to identify the development system before this can be answered with any detail. I'll answer as though you were using the aCC compiler but others will be very similar.

1) Compile each object as position independent code (PIC); for aCC that is the +z option.

aCC +z -c module1.c
aCC +z -c module2.c
aCC +z -c module3.c

The -c option tells aCC not to invoke the link editor (ld) phase and simply creat unlinked object files (module1.o, module2.o, module3.o).

2) Now invoke aCC using the -b option to create a shared library and -o to name the library output file.

aCC -b -o mymodules.sl module1.o module2.o module3.o.

The steps are similar in whatever development system you are using.

The arguments for the ANSI C compiler are also the same; simply replace aCC with cc.
If it ain't broke, I can fix that.
Ceaser123
Occasional Advisor

Re: Libraries

I still don't know enough to understand that responce. I think I'm using gcc.
ranganath ramachandra
Esteemed Contributor

Re: Libraries

there is no way to do that unless you have access to the source code and the development environment.

if you can say why this is required, some alternatives may come up.
 
--
ranga
hp-ux 11i v3[i work for hpe]

Accept or Kudo

H.Merijn Brand (procura
Honored Contributor

Re: Libraries

You can only do that if the objects in the original library are already compiled with +Z or +z (or when compiled with gcc with -fpic or -fPIC)

Asuming that is the case, you do not need a C compiler to convert the libs:

# cd /your/path/to/lib
# mkdir tmp
# cd tmp
# ar x ../libxxx.a
# ld -b -o ../liborg.sl *.o
# cd ..
# rm -rf tmp

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn