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.