[Top][All Lists]

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

Re: how to build gnulib for shared libraries?

From: Szabolcs Nagy
Subject: Re: how to build gnulib for shared libraries?
Date: Thu, 3 Jan 2019 15:58:17 +0000
User-agent: Mozilla/5.0 (X11; Linux aarch64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1

On 20/12/2018 03:18, Bruno Haible wrote:
> Hi Szabolcs,
> (or should I say "Hi Nagy"? Sorry, with Hungarian proper names, I never
> know what is the surname and what is the given name.)

(szabolcs is my given name, i only use the hungarian order
in hungarian language context)

>> by default gnulib is not built with -fPIC so it is not
>> suitable for shared libraries.
>> is there an easy way to build gnulib .a with -fPIC so
>> it can be used with shared libraries and executables as
>> well within the same project?
> The easy way is to use libtool, in combination with the technique
> described in
> https://www.gnu.org/software/gnulib/manual/html_node/Modified-build-rules.html
>  .
> You find an example here:
> https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=blob;f=gettext-tools/gnulib-lib/Makefile.am
> For shared libraries that are private to your application, this is all
> you need.

meanwhile i solved my issue in a completely different way
but it's good to know that libtool is the easy solution.

> For shared libraries that are visible to other applications, you should
> consider hiding the gnulib symbols. Since the set of gnulib symbols depends
> on the platform, I usually follow the approach to export only a given set
> of symbols (defined by .h files) and hide all the rest. Find an
> example of this technique here:
> https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=blob;f=gettext-tools/libgettextpo/Makefile.am
>> only elf targets need to be supported so ideally all
>> gnulib replacement symbols should have hidden visibility
> If all your targets support __attribute__((__visibility__("hidden"))),
> you can use the option determined by gnulib module 'lib-symbol-visibility'.
> Documentation:
> https://www.gnu.org/software/gnulib/manual/html_node/Exported-Symbols-of-Shared-Libraries.html
> Otherwise the only reliable way to hide symbols is by adding #define
> instructions through config.h.
>> object files should be built only once (with -fPIC)
> Try 'configure --disable-static --enable-shared'.
>> nor libtool dependency.
> libtool is part of the GNU build system. If you don't want libtool,
> you're on your own. You'll have different build rules for every platform,
> essentially. It can be done (look at libncurses, for example), though.

unfortunately libtool has a lot of issues which are
unlikely to be fixed any time soon.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]