centos6.9(32位)上的python编译失败

时间:2017-08-17 06:13:27

标签: python gcc makefile

您好我按照以下步骤操作:

 # wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz

 # tar xzf Python-2.7.13.tgz

 # cd Python-2.7.13

 # ./configure

 # make

 # make altinstall

它给了我以下编译错误:

gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE  -c ./Modules/symtablemodule.c -o Modules/symtablemodule.o
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE  -c ./Modules/xxsubtype.c -o Modules/xxsubtype.o
gcc -pthread -c -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE \
          -DSVNVERSION="\"`LC_ALL=C svnversion .`\"" \
          -DHGVERSION="\"`LC_ALL=C hg id -i .`\"" \
          -DHGTAG="\"`LC_ALL=C hg id -t .`\"" \
          -DHGBRANCH="\"`LC_ALL=C hg id -b .`\"" \
          -o Modules/getbuildinfo.o ./Modules/getbuildinfo.c
./Modules/getbuildinfo.c: In function 'Py_GetBuildInfo':
./Modules/getbuildinfo.c:45: error: expected ')' before 'default'
./Modules/getbuildinfo.c:46: error: expected ')' before 'default'
./Modules/getbuildinfo.c:46: error: expected ')' before 'default'
./Modules/getbuildinfo.c:47: error: expected ')' before 'default'
./Modules/getbuildinfo.c:47: error: expected ')' before 'default'
./Modules/getbuildinfo.c: In function '_Py_hgversion':
./Modules/getbuildinfo.c:72: error: expected ';' before 'default'
./Modules/getbuildinfo.c: In function '_Py_hgidentifier':
./Modules/getbuildinfo.c:79: error: expected ';' before 'default'
./Modules/getbuildinfo.c:83: error: expected ';' before 'default'
make: *** [Modules/getbuildinfo.o] Error 1

我尝试在线搜索,但无法找到任何解决方案...... 任何帮助表示赞赏

谢谢!

在查看下面的评论之后,我将功能更改为(标记为//< -added by me):

const char *
Py_GetBuildInfo(void)
{
//    static char buildinfo[50 + sizeof(HGVERSION) +
//                          ((sizeof(HGTAG) > sizeof(HGBRANCH)) ?
//                           sizeof(HGTAG) : sizeof(HGBRANCH))];
    static char buildinfo[500];  //<-added by me

    const char *revision = _Py_hgversion();
    const char *sep = *revision ? ":" : "";
    const char *hgid = _Py_hgidentifier();
    if (!(*hgid))
        hgid = "default";
    PyOS_snprintf(buildinfo, sizeof(buildinfo),
                  "%s%s%s, %.20s, %.9s", hgid, sep, revision,
                  DATE, TIME);
    return buildinfo;
}

const char *
_Py_svnversion(void)
{
    /* the following string can be modified by subwcrev.exe */
    static const char svnversion[] = SVNVERSION;
    if (svnversion[0] != '$')
        return svnversion; /* it was interpolated, or passed on command line */
    return "Unversioned directory";
}

const char *
_Py_hgversion(void)
{
    //return HGVERSION;
    return "Unversioned version";  //<-added by me

}

const char *
_Py_hgidentifier(void)
{
//    const char *hgtag, *hgid;        
//    hgtag = HGTAG;
//    if ((*hgtag) && strcmp(hgtag, "tip") != 0)
//        hgid = hgtag;
//    else
//        hgid = HGBRANCH;
//    return hgid;
   return "Unversioned id"; //<-added by me

}

我的问题是,如果它保存那样做?因为代码似乎编译,我可以安装它没有问题。

1 个答案:

答案 0 :(得分:0)

您可能想尝试以下方法 - 1)将所有mercurial包升级到最新版本,然后尝试构建python 2.7,如果仍然没有编译,那么 2)首先删除mercurial包,然后构建python 2.7,然后重新安装mercurial。