Discussion:
Integrating gnulib into shared library
(too old to reply)
Charlie Sale
2018-01-07 17:12:34 UTC
Permalink
Raw Message
Hello gnulib!

I am currently working on a project that uses the gnulib list utility
and distrubutes a shared library. My problem is that a static library
cannot be linked into a shared library, which means that gnulib is not
compiled into my project.

Is there an easy way that I can fix this? Can I directly add the gnulib
sources to my shared library? Is there another solution?

Thanks for your help!

Charlie
--
-----BEGIN PGP PUBLIC KEY BLOCK-----

mQENBFpKrgwBCADaPosQdy9rTpDmGp7y+m7QCW3w3AGtPgoBRJVwuXyOnRp/Q8Xg
jMaQF17GmRgy54+eZJJV5vQNrXAvTo7hX5lAjNTu0EawPE53zQZ7CFGT8YEjlJ8j
PYh5Tp02ckQxZQOZqyIQS2w2CqCZYhSeq2l50pNA2Rutxd2an1DBzdH/1zBnY5qo
r+8N5MgNBcvjgaWiT8kAefHHlD+ssWygg1yVUzxHbOoLWRi24o0mKn6a24fP5EHr
uZXfsoC1Vrhb8RjyftXw0DPFavx6Zi7VIHv68MB/aBVEtMHisCyHlfnqFTMcgKWh
hV5ZC5OR7ELNhNZ82+BoTVH5oA5bD5Hi9tklABEBAAG0J0NoYXJsaWUgU2FsZSA8
c29mdHdhcmVzYWxlMDFAZ21haWwuY29tPokBOAQTAQIAIgUCWkquDAIbAwYLCQgH
AwIGFQgCCQoLBBYCAwECHgECF4AACgkQjFElWoJ7azJvjgf/TtI2/F7xPRUzPaTi
opGbkPXgZMDrRCXK58NQMmUHXmLAwMx2MbfKOhu0hXvZw5ITlkN++bZyXZTiHLwf
fGU5BvtXFKoO8YcZtfbzsUSs3O31hNAuaEm3jwUR1LnoBYJk0Rv1/fnJKdwsUKO9
EvVRSv7CbQh3TLN1aH4RhUAf6NSvDiqv0AwKxceIZsRBf8AbsodlNpxZPay82M2X
YRMyv4sqbeLycXXqOxZMS8BGvzG1O0MobnJ7r/AsqAUUBQrHMEVhpaQgdJ4DMLDl
8KgaynN9vw6/hzl6HkeGHjk2BeUhQZ5Uae++Ot20q1+1b9SHv8YNmnC3PixXGz1G
nFyZ0bkBDQRaSq4MAQgAxWdDdccMwoKmaT6icAJGeFg3sNlgqJ8pF9sK6/QtObUl
fq/MQl2PLP5GjoH1rx8ptms7w3QeTEMJJZweSKD6Fot3R1mQ5mxkxIpR/t/5hS+n
WfqFM+Ri8Va51vBZetTge21ynKac1O1ZGIA2ySKPGexW/ouAWnpZIasmQ0LWnryh
aFNEB9ND0Eork6xjptXRGcBb98trCeiQAc4bffgHpC945f483dScdIcu192QAcY+
J9PAw8eY824s4stx8+Mvu3aaFb7SZEgAPN3WXgjMBY0jysxstAqfxxv78tHCt7uU
AOMRE2pS5nzbEcKakB2VuB4eRFVNb9Qk5Ogw+0wOGQARAQABiQEfBBgBAgAJBQJa
Sq4MAhsMAAoJEIxRJVqCe2sy/r4IAJl96tBtsk2y90J7oT1Z4KIW9zL/2lj//4FY
OU5MbGBMocmzSaosNIZDOQphzvJZGHtxpfp4WkZEU+5wi4n6OqAXoE9Uc8qKImfY
L7FXhRnnXpVuFZOpau/fSijKa5xpoGStBUE3rBm7l+U/FQqsXmmErij1EMcEu8fl
Qu2iFb1elkbticZMcczdAHPpNOwSffnhwx/sOsSqGmw0L+FgMkrnuOIpzMHhjKEC
6n63wBQG3IMNzMyUbsL35p7sz6pn8yk+WUB+NFFrIUbxlDMzRJg73ZZoivELBZik
KWTQS9fP5aQBXz5eNM7KE8v/+BIaNw4dG1i7pZKiFz5qGOkR8M0=
=0Ueh
-----END PGP PUBLIC KEY BLOCK-----
Bruno Haible
2018-01-07 19:34:47 UTC
Permalink
Raw Message
Hi,
Post by Charlie Sale
I am currently working on a project that uses the gnulib list utility
and distrubutes a shared library. My problem is that a static library
cannot be linked into a shared library, which means that gnulib is not
compiled into my project.
Is there an easy way that I can fix this?
The easiest way to fix this consists of two steps:

1) In the gnulib-tool invocation, use the option --libtool.
Rationale: Libtool libraries *can* be included in shared libraries.

2) Use an Automake *_LIBADD variable to specify that it should be linked
into your library:
libfoo_la_LDADD = libgnu.la ...

For an example of this technique, see the libgettextpo:
http://git.savannah.gnu.org/gitweb/?p=gettext.git;a=blob;f=gettext-tools/libgettextpo/Makefile.am

Bruno
Bruno Haible
2018-01-07 19:38:30 UTC
Permalink
Raw Message
PS: The documentation is already complete on this topic:
https://www.gnu.org/software/gnulib/manual/html_node/Multiple-instances.html
Charlie Sale
2018-01-07 19:51:02 UTC
Permalink
Raw Message
Post by Bruno Haible
https://www.gnu.org/software/gnulib/manual/html_node/Multiple-instances.html
Thank you. It worked perfectly. Sorry that I did not consult the
documentation first.

Charlie

Loading...