Re: Compiling for Shared Libraries

Waldek Hebisch <[email protected]>
Newsgroups gmane.comp.compilers.gpc
Message-ID <[email protected]>
Kevan Hashemi wrote:
> 
> I just compiled GPC from sources on both 32-bit and 64-bit Linux 
> machines. On both machines, I'm running Scientific Linux 6.4, a 
> derivative of Red Had Linux 6.4. The local C compiler is 4.4.7 in both 
> cases.
> 
> On the 32-bit machine, I can compile from Pascal to make objects, and 
> link them with libgpc.a to make a shared library. But on the 64-bit 
> machine I find that I must pass -fPIC to GPC to force it to compile 
> position-independent code for the subsequent link. Even then, libgpc.a 
> is position-dependent, so I can't link it into a shared library. So I 
> edit the GPC build's Makefile:
> 
> CFLAGS = -g -O2 -fPIC
> 
> Now I build GPC again and re-install. The new libgpc.a is 
> position-independent, and I can make my shared library.
> 
> Does anyone know why the default on 64-bit is position-dependent, while 
> on 32-bit it is position-independent?

By default gpc builds position-dependent libgpc.  On 32-bit i386
shared libraries may contain position-dependent code, on other
platforms, in particular for amd64 you need position-independent
code in shared libraries.

If you want shared libgpc, after buildiing gpc do:

cd gcc/p/rts
make clean
make WITH_SHARED=yes

I do not remember if there is any support for automatically
installing libgpc, if needed install resulting libgpc by hand.

-- 
                              Waldek Hebisch
[email protected] 

_______________________________________________
Gpc mailing list
[email protected]
https://www.g-n-u.de/mailman/listinfo/gpc
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.