当前位置:   article > 正文

mpc库问题导致gcc编译失败_checking for the correct version of mpc.h... no

checking for the correct version of mpc.h... no

使用 mpc-1.3.0 编译 gcc-13.1.0,执行 gcc 的 configure 时遇到如下错误:

checking for the correct version of gmp.h... yes
checking for the correct version of mpfr.h... yes
checking for the correct version of mpc.h... no
configure: error: Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+.
  • 1
  • 2
  • 3
  • 4

检查 mpc 版本:

  # Check for the MPC header version.
  if test "x$require_mpc" = xyes && test x"$have_gmp" = xyes ; then
    # Check for the recommended and required versions of MPC.
    AC_MSG_CHECKING([for the correct version of mpc.h])
    AC_TRY_COMPILE([#include <mpc.h>],[
    #if MPC_VERSION < MPC_VERSION_NUM(0,8,0)
    choke me
    #endif
    ], [AC_TRY_COMPILE([#include <mpc.h>],[
    #if MPC_VERSION < MPC_VERSION_NUM(0,8,1)
    choke me
    #endif
    ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([buggy but acceptable])])],
     [AC_MSG_RESULT([no]); have_gmp=no])
  fi
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
# cat x.cpp
#include <stdio.h>
#include <mpc.h>
int main() {
        printf("MPC_VERSION:%d\n", MPC_VERSION);
        printf("MPC_VERSION_NUM(0,8,0): %d\n", MPC_VERSION_NUM(0,8,0));
        return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
# g++ -g -o x x.cpp -I/usr/local/mpc/include -I/usr/local/gmp/include -I/usr/local/mpfr/include
# ./x
MPC_VERSION:66304
MPC_VERSION_NUM(0,8,0): 2048
  • 1
  • 2
  • 3
  • 4
  # Check for the MPC header version.
  if test "x$require_mpc" = xyes && test x"$have_gmp" = xyes ; then
    # Check for the recommended and required versions of MPC.
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the correct version of mpc.h" >&5
$as_echo_n "checking for the correct version of mpc.h... " >&6; }
    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include <mpc.h>
int
main ()
{

    #if MPC_VERSION < MPC_VERSION_NUM(0,8,0)
    choke me
    #endif

  ;
  return 0;
}
_ACEOF
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

在 config.log 找到的错误信息:

configure:8174: checking for the correct version of mpc.h
configure:8191: gcc -std=gnu99 -c -g -O2 -I/usr/local/gmp/include -I/usr/local/mpfr/include -I/usr/local/mpc/include   conftest.c >&5
In file included from conftest.c:10:0:
/usr/local/mpc/include/mpc.h:287:35: error: unknown type name 'FILE'
 __MPC_DECLSPEC void mpcr_out_str (FILE *f, mpcr_srcptr r);
                                   ^
configure:8191: $? = 1
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

打开 mpc.h,可以看到:

#include <stdint.h>
#include "gmp.h"
#include "mpfr.h"
  • 1
  • 2
  • 3

这里没有 include 头文件 stdio.h,导致错误”unknown type name ‘FILE’“,加上后即可消除错误:

#include <stdint.h>
#include <stdio.h>
#include "gmp.h"
#include "mpfr.h"
  • 1
  • 2
  • 3
  • 4

mpc 源代码仓库:

(https://gitlab.inria.fr/mpc/mpc)[https://gitlab.inria.fr/mpc/mpc]

解决办法,修改文件 mpc.h,添加“#include <stdio.h>”:

sed -i '/#include <stdint.h>/a\#include <stdio.h>' /usr/local/mpc/include/mpc.h
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/926697
推荐阅读
相关标签
  

闽ICP备14008679号