Operating System - HP-UX
1825782 Members
2180 Online
109687 Solutions
New Discussion

gnu cc, PIC, +z option etc, shared libs, DLLs

 
jp
Frequent Advisor

gnu cc, PIC, +z option etc, shared libs, DLLs

Not being a C guru, is this something I really want to get into? I am trying to build some DLLs, do I need to make PIC objects, .sl libs??

UX 11i, only gnu cc, Eloquence
TIA,
Jp
2 REPLIES 2
A. Clay Stephenson
Acclaimed Contributor

Re: gnu cc, PIC, +z option etc, shared libs, DLLs

First, don't call them DLL's -- that's a term from another OS. If you do want to make shared libraries then you must compile the objects as position-independent code (PIC); this is not a requirement if you wish to create objects for static libraries.
If it ain't broke, I can fix that.
H.Merijn Brand (procura
Honored Contributor

Re: gnu cc, PIC, +z option etc, shared libs, DLLs

And GNU gcc has a wonderful self-explaining option for that: -fpic (equal to +z) or -fPIC (equal to +Z)

# gcc -c -fPIC test.c
# ld -b -o test.sl test.o

There you have your shared library (briliant extention: .sl :)

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