简体   繁体   中英

No rule to make target `libpython2.6.a'

I am trying to compile Python2.6 from its source codes, and took steps as follow, and encountered an error message:

./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.

I reviewed the Makefile detail, and really could not find any rule to make the target 'libpythonXXX.a'. I googled around, and it seemed that no one had encountered the same issue as me?

In the Makefile, it really has a rule for making the target 'libpythonXXX.so'.

Works for me

$ 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
...

Really appriciating replies from @Jean-François Fabre and @Messa.

I repeated the steps of @Messa, and it really worked fine. So I tried to diff the 'Makefile.pre.in' from https://www.python.org/ftp/python/2.6/Python-2.6.tgz with the one I downloaded and rpminstalled from http://vault.centos.org/6.9/os/Source/SPackages/python-2.6.6-66.el6_8.src.rpm , and I found that the latter one had missing following pieces:

# 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) $@

That's the direct cause of the Make error message. Since I took following steps to attain the Python2.6 source code:

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):
...

It was the 'python-2.6.2-no-static-lib.patch' that had removed those pieces!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM