无法构建 GnuTLS,未定义对 gmp 的引用

问题描述

我想试用 GnuTLS (3.6.15)。我安装了 p11-kit、荨麻和 gmp。对于 libtasn1 和 unistring,我使用了 ./configure 标志(--with-included-unistring--with-included-libtasn1)。我正在使用的对 ./configure 的完整调用如下所示:./configure --with-included-unistring --with-included-libtasn1 --disable-ssl2-support --disable-cxx.
但是,无论我做什么,在某些时候我都会收到关于 mpn_*mpz_* 的未定义引用的错误。我多次重新安装 gmp 以希望解决问题。我还尝试手动告诉配置使用 -lgmp 标志,并提供了 gmp 的路径。到目前为止,我尝试过的任何解决方案都没有改变一件事。
我正在使用以下命令安装 gmp:

cd gmp-6.2.1
./configure
# which BTW outputs the following:
# configure: summary of build options:
# 
#   Version:           GNU MP 6.2.1
#   Host type:         kabylake-pc-linux-gnu
#   ABI:               64
#   Install prefix:    /usr/local
#   Compiler:          gcc
#   Static libraries:  yes
#   Shared libraries:  yes

make

# output:
#libtool: link: ranlib .libs/libgmp.a
#libtool: link: rm -fr .libs/libgmp.lax
#libtool: link: ( cd ".libs" && rm -f "libgmp.la" && ln -s "../libgmp.la" "libgmp.la" )

sudo make install

# output (only the end):
# /usr/bin/mkdir -p '/usr/local/lib'
# /bin/bash ./libtool   --mode=install /usr/bin/install -c   libgmp.la '/usr/local/lib'
#libtool: install: /usr/bin/install -c .libs/libgmp.so.10.4.1 /usr/local/lib/libgmp.so.10.4.1
#libtool: install: (cd /usr/local/lib && { ln -s -f libgmp.so.10.4.1 libgmp.so.10 || { rm -f #libgmp.so.10 && ln -s libgmp.so.10.4.1 libgmp.so.10; }; })
#libtool: install: (cd /usr/local/lib && { ln -s -f libgmp.so.10.4.1 libgmp.so || { rm -f #libgmp.so && ln -s libgmp.so.10.4.1 libgmp.so; }; })
#libtool: install: /usr/bin/install -c .libs/libgmp.lai /usr/local/lib/libgmp.la
#libtool: install: /usr/bin/install -c .libs/libgmp.a /usr/local/lib/libgmp.a
#libtool: install: chmod 644 /usr/local/lib/libgmp.a
#libtool: install: ranlib /usr/local/lib/libgmp.a
#libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin" ldconfig -n /usr/local/lib
#----------------------------------------------------------------------
#Libraries have been installed in:
#   /usr/local/lib
#
#If you ever happen to want to link against installed libraries
#in a given directory,LIBDIR,you must either use libtool,and
#specify the full pathname of the library,or use the '-LLIBDIR'
#flag during linking and do at least one of the following:
#   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
#     during execution
#   - add LIBDIR to the 'LD_RUN_PATH' environment variable
#     during linking
#   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
#   - have your system administrator add LIBDIR to '/etc/ld.so.conf'
#
#See any operating system documentation about shared libraries for
#more @R_437_4045@ion,such as the ld(1) and ld.so(8) manual pages.
#----------------------------------------------------------------------
# /usr/bin/mkdir -p '/usr/local/include'
# /usr/bin/install -c -m 644 gmp.h '/usr/local/include'
# /usr/bin/mkdir -p '/usr/local/lib/pkgconfig'
# /usr/bin/install -c -m 644 gmp.pc '/usr/local/lib/pkgconfig'

make check

# all tests passed

然后对于 GnuTLS 3.6.15:

./configure --with-included-unistring --with-included-libtasn1 --disable-ssl2-support --disable-cxx

#output (only the end):
# configure: summary of build options:
# 
#   version:              3.6.15 shared 58:1:28
#   Host/Target system:   x86_64-pc-linux-gnu
#   Build system:         x86_64-pc-linux-gnu
#   Install prefix:       /usr/local
#   Compiler:             gcc
#   Valgrind:             no 
#   CFlags:               -g -O2
#   Library types:        Shared=yes,Static=no
#   Local libopts:        yes
#   Local libtasn1:       yes
#   Local unistring:      yes
#   Use nettle-mini:      no
#   Documentation:        yes (manpages: yes)
# 
# configure: External hardware support:
# 
#   /dev/crypto:          no
#   Hardware accel:       x86-64
#   Padlock accel:        yes
#   Random gen. variant:  getrandom
#   PKCS#11 support:      yes
#   TPM support:          no
# 
# configure: Optional features:
# (note that included applications might not compile properly
# if features are disabled)
# 
#   SSL3.0 support:       no
#   SSL2.0 client hello:  no
#   Allow SHA1 sign:      no
#   DTLS-SRTP support:    yes
#   ALPN support:         yes
#   OCSP support:         yes
#   SRP support:          yes
#   PSK support:          yes
#   DHE support:          yes
#   ECDHE support:        yes
#   GOST support:         yes
#   Anon auth support:    yes
#   Heartbeat support:    yes
#   IDNA support:         no
#   Non-SuiteB curves:    yes
#   FIPS140 mode:         no
#   Strict DER time:    yes
# 
# configure: Optional libraries:
# 
#   Guile wrappers:       no
#   C++ library:          no
#   DANE library:         yes
#   OpenSSL compat:       no
# 
# configure: System files:
# 
#   Trust store pkcs11:   
#   Trust store dir:      
#   Trust store file:     /etc/ssl/certs/ca-certificates.crt
#   Blacklist file:       
#   CRL file:             
#   Configuration file:   /etc/gnutls/config
#   DNSSEC root key file: /usr/share/dns/root.key

make

# the end of output:
#   cclD     libcmd-psk.la
# ar: `u' modifier ignored since `D' is the default (see `U')
#   cclD     psktool
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_import'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_set_ui'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_sqrt'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_cdiv_q'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_limbs_finish'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_export'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpn_sub_n'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_mod'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_cmp'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_gcd'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_invert'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_fdiv_r_2exp'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_powm'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_tstbit'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_sgn'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_lcm'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_init_set_str'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpn_rshift'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpn_zero_p'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_set'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_probab_prime_p'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_tdiv_q_2exp'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_roinit_n'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_tdiv_r_2exp'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_sub_ui'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_mul'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_limbs_read'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_fdiv_r'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_mul_ui'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpn_zero'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_add_ui'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_mul_2exp'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_sizeinbase'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_fdiv_q_2exp'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpn_copyi'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_size'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_limbs_write'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_sub'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_init'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_clear'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_fdiv_q'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_cmp_ui'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpn_addmul_1'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpn_cmp'
# /usr/bin/ld: ../lib/.libs/libgnutls.so: undefined reference to `mpz_add'
# collect2: error: ld returned 1 exit status
# make[4]: *** [Makefile:2219: psktool] Error 1
# make[4]: Leaving directory '/tmp/gnutls-3.6.15/src'
# make[3]: *** [Makefile:2390: all-recursive] Error 1
# make[3]: Leaving directory '/tmp/gnutls-3.6.15/src'
# make[2]: *** [Makefile:2051: all] Error 2
# make[2]: Leaving directory '/tmp/gnutls-3.6.15/src'
# make[1]: *** [Makefile:1764: all-recursive] Error 1
# make[1]: Leaving directory '/tmp/gnutls-3.6.15'
# make: *** [Makefile:1689: all] Error 2

执行 export LDFLAGS="-lgmp" 之类的操作,然后重试 make 或将其位置提供给 gmp 似乎没有任何改变。我也尝试先执行 make clean,然后在 ./configure 之前立即重试 make。我确实尝试多次重新安装 GnuTLS 和 GMP 没有效果,也重新启动了一次。见鬼,我什至在失败的 sudo make install 之后尝试了 make,它甚至有效,+/-。但是,如果尝试使用 GnuTLS 编译一个简单的 C 程序,引用错误会再次出现,是的,我确实使用 -lgmp 进行了编译。
任何帮助表示赞赏。
使用 GCC 9.3.0。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)