Operating System - HP-UX
1833742 Members
2696 Online
110063 Solutions
New Discussion

ld - converting .a to .sl

 
Alex Green
Frequent Advisor

ld - converting .a to .sl

Hi All,

Can anyone tell me how I could convert .a archive library containing .o files into a .sl.

My problem is, I downloaded gettext from DSPP and I'm now trying to use bash from the porting center and it requires the shared lib libintl.sl, however gettext from DSPP only supplies the .a

Thanks in advance.

P.S. the other option of course is to build bash from source... however I really need to learn more about ld :).
"The physicist's greatest tool is his wastebasket." - Albert Einstein.
3 REPLIES 3
Olav Baadsvik
Esteemed Contributor

Re: ld - converting .a to .sl


Hi,

I think you will have to recompile the
source-code in this case.
The reason is that objects in a shared lib (.sl) have to be compiled with an option
for "position-independent code"
Most likely the objects in your .a file are
not compiled with this option.

Regards
Olav
Jean-Luc Oudart
Honored Contributor

Re: ld - converting .a to .sl

see ld man pages
ld -b produces a shared library.

Your objects ".o" must be compiled with the +Z option, (PIC) Position Independent Code otherwise you cannot build the shared lib.
see cc man pages

Jean-Luc
fiat lux
H.Merijn Brand (procura
Honored Contributor

Re: ld - converting .a to .sl

Jean-Luc is 100% OK

If and only if the objects are created with +z or +Z (-fpic or -fPIC for gcc) you might be able to convert:


# cd /usr/local/lib
# mkdir tmp
# cd tmp
# ar xf ../libmylib.a
# ld -b -o libmylib.sl *.o
# mv libmylib.sl ..
# cd ..
# rm -rf tmp
# ls -al libmylib.*
Enjoy, Have FUN! H.Merijn