RE: how to build shared library link to a static library

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I agree that adding fPIC will solve your particular problem; the bigger question is whether there is any reason you would *not* want to add that flag to the components in a static library.   I do not know the answer to that question.
Daryl

-----Original Message-----
From: Wu, Wendy 
Sent: Wednesday, April 24, 2019 9:23 AM
To: Jonathan Wakely <jwakely.gcc@xxxxxxxxx>
Cc: gcc-help@xxxxxxxxxxx; Poe, Daryl (Thin Clients) <daryl.poe@xxxxxx>
Subject: RE: how to build shared library link to a static library

Thank you very much.

-----Original Message-----
From: Jonathan Wakely <jwakely.gcc@xxxxxxxxx>
Sent: Wednesday, April 24, 2019 10:21 AM
To: Wu, Wendy <jian.wu3@xxxxxx>
Cc: gcc-help@xxxxxxxxxxx
Subject: Re: how to build shared library link to a static library

On Wed, 24 Apr 2019 at 15:42, Wu, Wendy <jian.wu3@xxxxxx> wrote:
>
> Hi GCC team member,
> I am using 64 bit Linux.
> I have a library : libstatic.a, which has function: sfun(); I need to 
> build a library: libshared.so, which uses sfun(); but I got error “ `.rodata' can not be used when making a shared object; recompile with -fPIC”
> Add -fPIC to libstatic.a Makefile could resolve the issue.
> libstatic.a team reject to add this option, and they told me -fPIC is only for shared library.

-fPIC is for relocatable code. If you want to include code in a shared library it needs to be relocatable.

> I checked gcc document, it shows -fPIC is for shared library too.
> Could you tell me how to resolve my problem? What’s the official way to link a static 64 bit library to a shared 64bit library?

Either don't use libstatic.a or build it with -fPIC.





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux