没有规则使目标“libpython2.6.a”

2024-10-03 00:29:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试从其源代码编译Python2.6,并采取了以下步骤,但遇到了一条错误消息:

./configure
...
[root@KuGouIdc Python-2.6.6]# ls
config.log                                 Demo        Makefile.pre                       Objects                                     Python
config.status                              Doc         Makefile.pre.in                    Parser                                      README
configure                                  Grammar     Makefile.pre.in.cflags             PC                                          RISCOS
configure.in                               Include     Makefile.pre.in.fix-parallel-make  PCbuild                                     setup.py
configure.in.check-for-XML_SetHashSalt     install-sh  Makefile.pre.in.lib64              pyconfig.h                                  setup.py.add-RPATH-to-pyexpat
configure.in.disable-pymalloc-on-valgrind  Lib         Makefile.pre.in.no-static-lib      pyconfig.h.in                               setup.py.expat
configure.in.expat                         LICENSE     Makefile.pre.in.systemtap          pyconfig.h.in.disable-pymalloc-on-valgrind  setup.py.lib64
configure.in.rpath                         Mac         Misc                               pyconfig.h.in.systemtap                     systemtap-example.stp
configure.in.systemtap                     Makefile    Modules                            pyfuntop.stp                                Tools
[root@KuGouIdc Python-2.6.6]# make -n all
gcc -pthread -c -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE -o Modules/python.o ./Modules/python.c
make: *** No rule to make target `libpython2.6.a', needed by `python'.  Stop.

我查看了Makefile的详细信息,但确实找不到任何使目标为“libpythonXXX.a”的规则。我搜索了一下,似乎没有人遇到过和我一样的问题?你知道吗

在Makefile中,它确实有一个规则来生成目标的libpythonXXX.so文件'. 你知道吗


Tags: inpymodulesconfigmakeincludeconfiguresetup
2条回答

非常感谢@Jean-François Fabre和@Messa的回复。你知道吗

我重复了@Messa的步骤,效果很好。所以我试着区分Makefile.pre.in'fromhttps://www.python.org/ftp/python/2.6/Python-2.6.tgz与我从http://vault.centos.org/6.9/os/Source/SPackages/python-2.6.6-66.el6_8.src.rpm下载并安装的rpmin一起,我发现后者缺少以下内容:

# Build static library
# avoid long command lines, same as LIBRARY_OBJS
$(LIBRARY): $(LIBRARY_OBJS)
       -rm -f $@
       $(AR) cr $@ Modules/getbuildinfo.o
       $(AR) cr $@ $(PARSER_OBJS)
       $(AR) cr $@ $(OBJECT_OBJS)
       $(AR) cr $@ $(PYTHON_OBJS)
       $(AR) cr $@ $(MODULE_OBJS) $(SIGNAL_OBJS)
       $(AR) cr $@ $(MODOBJS)
       $(RANLIB) $@

这是Make错误消息的直接原因。因为我采取了以下步骤来获得Python2.6源代码:

wget http://vault.centos.org/6.9/os/Source/SPackages/python-2.6.6-66.el6_8.src.rpm
rpm -i python-2.6.6-66.el6_8.src.rpm
cd ~/rpmbuild/SPECS
rpmbuild -bp  nodeps python.spec
...
Patch #111 (python-2.6.2-no-static-lib.patch):
...

它是python-2.6.2-no-static-库修补程序“把那些碎片都拿走了!你知道吗

对我有用

$ docker run  rm -it debian:stretch
# mkdir /src
# cd /src
# apt update
# apt install wget build-essential
# wget https://www.python.org/ftp/python/2.6/Python-2.6.tgz
# tar xzf Python-2.6.tgz
# cd Python-2.6
# ./configure
...
# make -n all
gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE -o Modules/python.o ./Modules/python.c
gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE -o Parser/acceler.o Parser/acceler.c
gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE -o Parser/grammar1.o Parser/grammar1.c
gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE -o Parser/listnode.o Parser/listnode.c
gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE -o Parser/node.o Parser/node.c
...

相关问题 更多 >