Skip to content

Cannot use a static built libidn2 library inside a shared library

Hello!

When using a static libidn2 library inside a shared library, linking fails with the following error:

/usr/bin/ld: ../lib/libgetdns.so.10.1.3: version node not found for symbol _idn2_punycode_decode@IDN2_0.0.0
/usr/bin/ld: failed to set dynamic section sizes: bad value

The symptoms look the same as this qt issue: https://bugreports.qt.io/browse/QTBUG-52605

I can fix this by applying the following patch on the 2.3.0 release:

--- lib/puny_decode.c
+++ lib/puny_decode.c
@@ -224,7 +224,7 @@
 
 /* Create a compatibility symbol if supported.  Hidden references make
    the target symbol hidden, hence the alias.  */
-#ifdef HAVE_SYMVER_ALIAS_SUPPORT
+#if 0
 __typeof__ (_idn2_punycode_decode_internal) _idn2_punycode_decode
    __attribute__ ((visibility ("default"),
                    alias ("_idn2_punycode_decode_internal")));
--- lib/puny_encode.c
+++ lib/puny_encode.c
@@ -225,7 +225,7 @@
 
 /* Create a compatibility symbol if supported.  Hidden references make
    the target symbol hidden, hence the alias.  */
-#ifdef HAVE_SYMVER_ALIAS_SUPPORT
+#if 0
 __typeof__ (_idn2_punycode_encode_internal) _idn2_punycode_encode
    __attribute__ ((visibility ("default"),
                    alias ("_idn2_punycode_encode_internal")));
``
But there are probably better ways to approach this.
Thanks!