Page MenuHome GnuPG

Building static GnuPG 2.1.2 fails due to multiply defined symbols.
Closed, ResolvedPublic

Description

Building static GnuPG 2.1.2 fails due to multiply defined symbols.

Command sequence:

+ LANG=C
+ LC_ALL=C
+ export LANG LC_ALL
+ unset CC CFLAGS CPP CPPFLAGS CC_FOR_BUILD
+ unset LDFLAGS
+ unset CCAS CCASFLAGS
+ unset CXX CXXFLAGS CXXCPP
+ unset F77 FFLAGS
+ unset YACC YFLAGS
+ export CC CFLAGS CPP CPPFLAGS CC_FOR_BUILD
+ export LDFLAGS
+ export CCAS CCASFLAGS
+ export CXX CXXFLAGS CXXCPP
+ export F77 FFLAGS
+ export YACC YFLAGS
+ prefix=/PREFIX
+ export
PATH=/PREFIX/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/lpp/mmfs/bin:/root/bin
+ /bin/rm -rf work
+ mkdir work

+ cd work
+ tar jvxf ../gnupg-1.4.18.tar.bz2
+ cd gnupg-1.4.18
+ ./configure --prefix=/PREFIX
+ make
+ sudo make install
+ cd ../..

+ cd work
+ tar jvxf ../npth-1.1.tar.bz2
+ cd npth-1.1
+ ./configure --prefix=/PREFIX --enable-static --disable-shared
+ make
+ sudo make install
+ cd ../..

+ cd work
+ tar jvxf ../libgpg-error-1.18.tar.bz2
+ cd libgpg-error-1.18
+ ./configure --prefix=/PREFIX --enable-static --disable-shared
+ make
+ sudo make install
+ cd ../..

+ cd work
+ tar jvxf ../libassuan-2.2.0.tar.bz2
+ cd libassuan-2.2.0
+ ./configure --prefix=/PREFIX --enable-static --disable-shared
--with-gpg-error-prefix=/PREFIX
+ make
+ sudo make install
+ cd ../..

+ cd work
+ tar jvxf ../libgcrypt-1.6.2.tar.bz2
+ cd libgcrypt-1.6.2
+ ./configure --prefix=/PREFIX --enable-static --disable-shared
--with-gpg-error-prefix=/PREFIX
+ make
+ sudo make install
+ cd ../..

+ cd work
+ tar jvxf ../libksba-1.3.2.tar.bz2
+ cd libksba-1.3.2
+ ./configure --prefix=/PREFIX --enable-static --disable-shared
--with-gpg-error-prefix=/PREFIX
+ make
+ sudo make install
+ cd ../..

+ cd work
+ tar jvxf ../pinentry-0.9.0.tar.bz2
+ cd pinentry-0.9.0
+ ./configure --prefix=/PREFIX --disable-pinentry-gtk2 --enable-pinentry-tty
+ make
+ sudo make install
+ cd ../..

+ cd work
+ tar jvxf ../gnupg-2.1.2.tar.bz2
+ cd gnupg-2.1.2
+ ./configure --prefix=/PREFIX --with-gpg-error-prefix=/PREFIX
--with-npth-prefix=/PREFIX --with-libassuan-prefix=/PREFIX
--with-libgcrypt-prefix=/PREFIX --with-ksba-prefix=/PREFIX
--with-pinentry-pgm=/PREFIX/bin/pinentrywrapper
+ make

This make fails when linking t-stringhelp because gcry_free and other
symbols are multiply defined, in "gnupg-2.1.2/common/t-support.c" and
in "libgcrypt-1.6.2/src/visibility.c".

Complete error message of this step:

gcc -I/PREFIX/include -I/PREFIX/include -I/PREFIX/include -g -O2 -Wall
-Wno-pointer-sign -Wpointer-arith -o t-stringhelp t-stringhelp.o t-support.o
libcommon.a -L/PREFIX/lib -lgcrypt -lgpg-error -lassuan -L/PREFIX/lib
-lgpg-error -L/PREFIX/lib -lgpg-error
/PREFIX/lib/libgcrypt.a(libgcrypt_la-visibility.o): In function `gcry_free':
/root/devel/rpgpg/work/libgcrypt-1.6.2/src/visibility.c:1525: multiple
definition of `gcry_free'
t-support.o:/root/devel/rpgpg/work/gnupg-2.1.2/common/t-support.c:123: first
defined here
/usr/bin/ld: Warning: size of symbol `gcry_free' changed from 18 in t-support.o
to 5 in /PREFIX/lib/libgcrypt.a(libgcrypt_la-visibility.o)
/PREFIX/lib/libgcrypt.a(libgcrypt_la-visibility.o): In function `gcry_xstrdup':
/root/devel/rpgpg/work/libgcrypt-1.6.2/src/visibility.c:1519: multiple
definition of `gcry_xstrdup'
t-support.o:/root/devel/rpgpg/work/gnupg-2.1.2/common/t-support.c:112: first
defined here
/usr/bin/ld: Warning: size of symbol `gcry_xstrdup' changed from 75 in
t-support.o to 5 in /PREFIX/lib/libgcrypt.a(libgcrypt_la-visibility.o)
/PREFIX/lib/libgcrypt.a(libgcrypt_la-visibility.o): In function `gcry_xrealloc':
/root/devel/rpgpg/work/libgcrypt-1.6.2/src/visibility.c:1513: multiple
definition of `gcry_xrealloc'
t-support.o:/root/devel/rpgpg/work/gnupg-2.1.2/common/t-support.c:85: first
defined here
/usr/bin/ld: Warning: size of symbol `gcry_xrealloc' changed from 29 in
t-support.o to 5 in /PREFIX/lib/libgcrypt.a(libgcrypt_la-visibility.o)
/PREFIX/lib/libgcrypt.a(libgcrypt_la-visibility.o): In function `gcry_xcalloc':
/root/devel/rpgpg/work/libgcrypt-1.6.2/src/visibility.c:1495: multiple
definition of `gcry_xcalloc'
t-support.o:/root/devel/rpgpg/work/gnupg-2.1.2/common/t-support.c:102: first
defined here
/usr/bin/ld: Warning: size of symbol `gcry_xcalloc' changed from 29 in
t-support.o to 5 in /PREFIX/lib/libgcrypt.a(libgcrypt_la-visibility.o)
/PREFIX/lib/libgcrypt.a(libgcrypt_la-visibility.o): In function `gcry_xmalloc':
/root/devel/rpgpg/work/libgcrypt-1.6.2/src/visibility.c:1489: multiple
definition of `gcry_xmalloc'
t-support.o:/root/devel/rpgpg/work/gnupg-2.1.2/common/t-support.c:60: first
defined here
/usr/bin/ld: Warning: size of symbol `gcry_xmalloc' changed from 29 in
t-support.o to 5 in /PREFIX/lib/libgcrypt.a(libgcrypt_la-visibility.o)
/PREFIX/lib/libgcrypt.a(libgcrypt_la-visibility.o): In function `gcry_strdup':
/root/devel/rpgpg/work/libgcrypt-1.6.2/src/visibility.c:1483: multiple
definition of `gcry_strdup'
t-support.o:/root/devel/rpgpg/work/gnupg-2.1.2/common/t-support.c:69: first
defined here
/usr/bin/ld: Warning: size of symbol `gcry_strdup' changed from 68 in
t-support.o to 5 in /PREFIX/lib/libgcrypt.a(libgcrypt_la-visibility.o)
/PREFIX/lib/libgcrypt.a(libgcrypt_la-visibility.o): In function `gcry_realloc':
/root/devel/rpgpg/work/libgcrypt-1.6.2/src/visibility.c:1477: multiple
definition of `gcry_realloc'
t-support.o:/root/devel/rpgpg/work/gnupg-2.1.2/common/t-support.c:80: first
defined here
/PREFIX/lib/libgcrypt.a(libgcrypt_la-visibility.o): In function `gcry_calloc':
/root/devel/rpgpg/work/libgcrypt-1.6.2/src/visibility.c:1459: multiple
definition of `gcry_calloc'
t-support.o:/root/devel/rpgpg/work/gnupg-2.1.2/common/t-support.c:97: first
defined here
/PREFIX/lib/libgcrypt.a(libgcrypt_la-visibility.o): In function `gcry_malloc':
/root/devel/rpgpg/work/libgcrypt-1.6.2/src/visibility.c:1453: multiple
definition of `gcry_malloc'
t-support.o:/root/devel/rpgpg/work/gnupg-2.1.2/common/t-support.c:55: first
defined here
/PREFIX/lib/libgpg-error.a(libgpg_error_la-visibility.o): In function
`gpg_err_code_from_syserror':
/root/devel/rpgpg/work/libgpg-error-1.18/src/visibility.c:59: multiple
definition of `gpg_err_code_from_syserror'
t-support.o:/root/devel/rpgpg/work/gnupg-2.1.2/common/t-support.c:151: first
defined here
/usr/bin/ld: Warning: size of symbol `gpg_err_code_from_syserror' changed from
29 in t-support.o to 5 in /PREFIX/lib/libgpg-error.a(libgpg_error_la-visibility.o)
/PREFIX/lib/libgpg-error.a(libgpg_error_la-visibility.o): In function
`gpg_err_code_from_errno':
/root/devel/rpgpg/work/libgpg-error-1.18/src/visibility.c:47: multiple
definition of `gpg_err_code_from_errno'
t-support.o:/root/devel/rpgpg/work/gnupg-2.1.2/common/t-support.c:137: first
defined here
/usr/bin/ld: Warning: size of symbol `gpg_err_code_from_errno' changed from 29
in t-support.o to 5 in /PREFIX/lib/libgpg-error.a(libgpg_error_la-visibility.o)
collect2: ld returned 1 exit status

The same build with GnuPG 2.0.x (plus dirmngr, of course) is successful.

Details

Version
2.1.2

Event Timeline

perske added projects: gnupg, Bug Report.
perske added a subscriber: perske.
werner lowered the priority of this task from High to Normal.Mar 4 2015, 12:39 PM
werner added a subscriber: werner.

What platform? Did you run ldconfig after installing a library?

Platform: Red Hat Enterprise Linux 5.11

ldconfig: I did not (assuming that make install does it if necessary)

Running "sudo ldconfig" after each "sudo make install" does not help.

gniibe added a project: Restricted Project.

Thank you, but I regret, the patch does not change anything.
(I have made the corresponding change in common/Makefile.in, too,
with same result.)

Umm... Could you try 'make distclean', then 'configure && make'? t-support.o is
not the target to build any more by the patch,
so, it should not be linked to t-stringhelp.
When you change common/Makefile.am and common/Makefile.in, common/Makefile
should be generated again,
but it would not be generated, perhaps.

no change: I had already tried installing from scratch working in an empty
directory.

On 04/23/2015 05:20 PM, Rainer Perske via BTS wrote:

no change: I had already tried installing from scratch working in an empty
directory.

Thanks for your time.

If your build for t-stringhelp (or t_timestuff) still includes
t-support.o, I think that it's the problem of automake which generates
Makefile.in.

Or, did you manually edit Makefile.in (instead of automake)?

In that case, you need to remove the line for t-support.$(OBJEXT) in

Makefile.in, too (like regeneration by automake does).

See the description of my build steps in my original report: After

+ tar jvxf ../gnupg-2.1.2.tar.bz2
+ cd gnupg-2.1.2

I manually changed both common/Makefile.am and common/Makefile.in and then
continued with

+ ./configure --prefix=/PREFIX --with-gpg-error-prefix=/PREFIX
--with-npth-prefix=/PREFIX --with-libassuan-prefix=/PREFIX
--with-libgcrypt-prefix=/PREFIX --with-ksba-prefix=/PREFIX
--with-pinentry-pgm=/PREFIX/bin/pinentrywrapper
+ make

I mean, when you manually edit common/Makefile.in, you need to edit the variable
am__objects_18, so that it won't include the object generated by t-support.c.

A big step forward :-)

With the command sequence

+ [... for building prerequisites see original bug report ...]
+ tar jvxf ../gnupg-2.1.2.tar.bz2
+ cd gnupg-2.1.2
+ /bin/cp -i common/Makefile.am common/Makefile.am.orig </dev/null || true
+ /bin/cp -i common/Makefile.in common/Makefile.in.orig </dev/null || true
+ s1='s|^t_jnlib_src = t-support\.c t-support\.h$|t_jnlib_src = t-support.h|'
+ s2='s|^amobjects_18 = t-support\.\$(OBJEXT)$|amobjects_18 =|'
+ /bin/sed "$s1" <common/Makefile.am.orig >common/Makefile.am
+ /bin/sed "$s1;$s2" <common/Makefile.in.orig >common/Makefile.in
+ ./configure --prefix=/PREFIX --with-gpg-error-prefix=/PREFIX
--with-npth-prefix=/PREFIX --with-libassuan-prefix=/PREFIX
--with-libgcrypt-prefix=/PREFIX --with-ksba-prefix=/PREFIX
--with-pinentry-pgm=/PREFIX/bin/pinentrywrapper
+ make

the build process fails later:

[...]
make[2]: Leaving directory `/root/devel/rpgpg/work/gnupg-2.1.2/sm'
Making all in agent
make[2]: Entering directory `/root/devel/rpgpg/work/gnupg-2.1.2/agent'
[...]
gcc -I/PREFIX/include -I/PREFIX/include -I/PREFIX/include -I/PREFIX/include -g
-O2 -Wall -Wno-pointer-sign -Wpointer-arith -o gpg-agent gpg_agent-gpg-agent.o
gpg_agent-command.o gpg_agent-command-ssh.o gpg_agent-call-pinentry.o
gpg_agent-cache.o gpg_agent-trans.o gpg_agent-findkey.o gpg_agent-pksign.o
gpg_agent-pkdecrypt.o gpg_agent-genkey.o gpg_agent-protect.o
gpg_agent-trustlist.o gpg_agent-divert-scd.o gpg_agent-cvt-openpgp.o
gpg_agent-call-scd.o gpg_agent-learncard.o ../common/libcommonpth.a
-L/PREFIX/lib -lgcrypt -lgpg-error -lassuan -L/PREFIX/lib -lgpg-error
-L/PREFIX/lib -lnpth -lpthread -L/PREFIX/lib -lgpg-error
/PREFIX/lib/libnpth.a(npth.o): In function `npth_clock_gettime':
/root/devel/rpgpg/work/npth-1.1/src/npth.c:699: undefined reference to
`clock_gettime'
collect2: ld returned 1 exit status
make[2]: * [gpg-agent] Error 1
make[2]: Leaving directory `/root/devel/rpgpg/work/gnupg-2.1.2/agent'
make[1]:
* [all-recursive] Error 1
make[1]: Leaving directory `/root/devel/rpgpg/work/gnupg-2.1.2'
make: *** [all] Error 2

Shall we keep in this issue or open a new one?

Thanks. No, you don't need to create another issue, since it's known simple issue.

Old system has clock_gettime function in librt. Please link with -lrt.
It would be good for npth's configure script to detect this for its build time.
I'll consider about that.

That's it! Setting

+ export LDFLAGS=-lrt

and then running the build process as described in my original report and in
msg6216, compilation is successful.

Thank you very, very much!

Great. Thanks for your work!
(With these fixes, I am now able to test whether T1644 is solved in 2.1.2,
unfortunately it is not.)