how to build shared library link to a static library
Wu, Wendy
jian.wu3@hp.com
Wed Apr 24 15:22:00 GMT 2019
Thank you very much.
-----Original Message-----
From: Jonathan Wakely <jwakely.gcc@gmail.com>
Sent: Wednesday, April 24, 2019 10:21 AM
To: Wu, Wendy <jian.wu3@hp.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: how to build shared library link to a static library
On Wed, 24 Apr 2019 at 15:42, Wu, Wendy <jian.wu3@hp.com> 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.
More information about the Gcc-help
mailing list