{"id":1681,"date":"2015-12-29T13:56:25","date_gmt":"2015-12-29T05:56:25","guid":{"rendered":"http:\/\/www.51cos.com\/?p=1681"},"modified":"2015-12-29T14:07:06","modified_gmt":"2015-12-29T06:07:06","slug":"%e5%9c%a8ubuntu-14-04mips-linux-gnu-gcc%e4%b8%8b%e7%bc%96%e8%af%91python2-7-1","status":"publish","type":"post","link":"http:\/\/www.51cos.com\/?p=1681","title":{"rendered":"\u5728UBUNTU 14.04+mips-linux-gnu-gcc\u4e0b\u7f16\u8bd1Python2.7.1"},"content":{"rendered":"<p>\u8d70\u4e86\u5f88\u591a\u5f2f\u8def\uff0c\u7f51\u4e0a\u7684\u65b9\u6cd5\u53ea\u80fd\u53c2\u8003\uff0c\u81ea\u5df1\u7528\u7684\u65f6\u5019\u6839\u672c\u65e0\u6cd5\u7f16\u8bd1\u8fc7\u53bb\uff0c\u8fd8\u597d\u82b1\u4e86\u4e00\u5929\u534a\u65f6\u95f4\uff0c\u6700\u7ec8\u89e3\u6389\u4e86\u3002<br \/>\n\u603b\u7ed3\u5b9d\u8d35\u7684\u7ecf\u9a8c\u5982\u4e0b\uff1a<\/p>\n<p>1\u3001\u4e0b\u8f09python http:\/\/www.python.org\/ftp\/python\/2.7\/Python-2.7.1.tar.bz2\uff0c\u6216\u8005http:\/\/www.python.org\/ftp\/python\u4e0b\u9762\u627e\u81ea\u5df1\u60f3\u7528\u7684\u7248\u672c\uff0c\u672c\u6587\u4ef6\u4ec5\u4f9bPython-2.7.1\u7248\u672c\u53c2\u8003<\/p>\n<p>2\u3001\u89e3\u58d3 tar xjvf Python-2.7.1.tar.bz2<\/p>\n<p>3\u3001\u8981\u5148\u751f\u6210\u4e00\u500bpgen\uff1a<\/p>\n<pre class=\"prettyprint linenums\" >\ncd Python-2.7.1<br \/>\nmkdir build.pc<br \/>\ncd build.pc<br \/>\n..\/configure<br \/>\nmake Parser\/pgen<\/p>\n<p>\u7136\u5f8cls Parser\u4e00\u4e0b\uff0c\u61c9\u8a72\u5c31\u80fd\u770b\u5230\u6709pgen\u4e86\u3002<\/p>\n<p>4\u3001\u914d\u7f6e<\/p>\n<p>--prefix\u540e\u9762\u7684\u8def\u5f84\u8bf7\u6539\u6210\u81ea\u5df1\u7684\uff1a<\/p>\n<pre class=\"prettyprint linenums\" >\ncd ..\/<br \/>\necho ac_cv_file__dev_ptmx=no > config.site<br \/>\necho ac_cv_file__dev_ptc=no >> config.site<br \/>\n.\/configure --prefix=\/home\/denny\/Project\/python_install --host=mips-linux-gnu \"CC=mips-linux-gnu-gcc -EL\" \"CFLAGS=-EL\" \"LDFLAGS=-EL\"<\/p>\n<p>5\u3001\u4fee\u6539Makefile\uff1a<\/p>\n<p>\uff081\uff09\u628a<\/p>\n<pre class=\"prettyprint linenums\" >\nOPT= -DNDEBUG -g -O3 -Wall -Wstrict-prototypes<\/p>\n<p>\u6539\u6210<\/p>\n<pre class=\"prettyprint linenums\" >\nOPT= -DNDEBUG -O2 -Wall -Wstrict-prototypes<\/p>\n<p>\u53bb\u6389-g\uff0c\u4e0d\u8981debug python\uff0c-O3\u6539\u70ba-O2\uff0c\u7a7a\u9593\u7dca\u5f35O2\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>\uff082\uff09\u5728\uff1a<\/p>\n<pre class=\"prettyprint linenums\" >\nPGEN= Parser\/pgen$(EXE)<\/p>\n<p>\u4e00\u884c\u7684\u4e0b\u9762\u52a0\u4e0a\uff1a<\/p>\n<pre class=\"prettyprint linenums\" >\nPGEN_HOST= build.pc\/Parser\/pgen$(EXE)<\/p>\n<p>\u8868\u660e\u6211\u5011\u5728HOST\u4e0a\u904b\u884c\u7684pgen\u3002<\/p>\n<p>\uff083\uff09\u5728\u8981\u4f7f\u7528PGEN\u7684\u5730\u65b9\u6539\u70baPGEN_HOST\uff1a<\/p>\n<pre class=\"prettyprint linenums\" >\n<span class=\"katex math inline\">(GRAMMAR_H)<\/span>(GRAMMAR_C): <span class=\"katex math inline\">(PGEN)<\/span>(GRAMMAR_INPUT)<\/p>\n<p>-<span class=\"katex math inline\">(PGEN)<\/span>(GRAMMAR_INPUT) <span class=\"katex math inline\">(GRAMMAR_H)<\/span>(GRAMMAR_C)<\/p>\n<p>\u6539\u70ba\uff1a<\/p>\n<pre class=\"prettyprint linenums\" >\n<span class=\"katex math inline\">(GRAMMAR_H)<\/span>(GRAMMAR_C): <span class=\"katex math inline\">(PGEN)<\/span>(GRAMMAR_INPUT)<\/p>\n<p>-<span class=\"katex math inline\">(PGEN_HOST)<\/span>(GRAMMAR_INPUT) <span class=\"katex math inline\">(GRAMMAR_H)<\/span>(GRAMMAR_C)<\/p>\n<p>\uff084\uff09\u4fee\u6539\u6240\u6709\u4f7f\u7528\u65b0\u751f\u6210\u7684python\u7684\u5730\u65b9\uff0c\u53ef\u4ee5\u7528gedit\u7684\u66ff\u6362\u529f\u80fd\uff0c\u603b\u5171\u670916\u4e2a\u5730\u65b9\uff1a<\/p>\n<p>\u6240\u6709<\/p>\n<pre class=\"prettyprint linenums\" >\n .\/$(BUILDPYTHON)<br \/>\n  \u7684\u5730\u65b9\uff0c\u90fd\u6539\u70ba<\/p>\n<pre class=\"prettyprint linenums\" >\npython<br \/>\n \uff0c\u5982\uff1a<\/p>\n<pre class=\"prettyprint linenums\" >\nplatform: <span class=\"katex math inline\">(BUILDPYTHON)<\/span>(RUNSHARED) .\/<span class=\"katex math inline\">(BUILDPYTHON) -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+\"-\"+sys.version[0:3]' >platform<\/p>\n<p>#\u6539\u70ba\uff1a<\/p>\n<p>platform:<\/span>(BUILDPYTHON)<\/p>\n<p>$(RUNSHARED) python -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+\"-\"+sys.version[0:3]' >platform<\/p>\n<p>6\u3001make \u51fa\u73fe\u932f\u8aa4\uff1a<\/p>\n<p>Include\/pyport.h:243: error: #error \"This platform's pyconfig.h needs to define PY_FORMAT_LONG_LONG\"<\/p>\n<p>\u4fee\u6539pyconfig.h: \u627e\u5230<\/p>\n<pre class=\"prettyprint linenums\" >\n#undef PY_FORMAT_LONG_LONG<br \/>\n \u540e\u9762\u6dfb\u52a0\u4e00\u884c\uff1a<\/p>\n<pre class=\"prettyprint linenums\" >\n#define PY_FORMAT_LONG_LONG \"ll\"<\/p>\n<p>7\u3001make,make install<\/p>\n<p>\u5982\u679c\u6ca1\u6709\u9519\u8bef\uff0c\u8bf4\u660e\u7f16\u8bd1\u6210\u529f\u4e86\uff01<\/p>\n<p>\u5982\u679c\u51fa\u73b0\u9519\u8bef\uff1a<br \/>\n.\/regen: line 3: \/home\/denny\/Project\/Python-2.7.1\/python: cannot execute binary file: Exec format error<br \/>\nmake: *** [Lib\/plat-linux3] Error 126<\/p>\n<pre class=\"prettyprint linenums\" >\nrunning build_scripts<br \/>\nmkdir .\/Lib\/plat-linux3<br \/>\ncp .\/Lib\/plat-generic\/regen .\/Lib\/plat-linux3\/regen<br \/>\nexport PATH; PATH=\"`pwd`:<span class=\"katex math inline\">PATH\"; \\<br \/>\n\texport PYTHONPATH; PYTHONPATH=\"`pwd`\/Lib\"; \\<br \/>\n\texport DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH=\"`pwd`\"; \\<br \/>\n\texport EXE; EXE=\"\"; \\<br \/>\n\tcd .\/Lib\/plat-linux3;  .\/regen<br \/>\npython<\/span>EXE ..\/..\/Tools\/scripts\/h2py.py -i '(u_long)' \/usr\/include\/netinet\/in.h<br \/>\n.\/regen: line 3: \/home\/denny\/Project\/Python-2.7.1\/python: cannot execute binary file: Exec format error<br \/>\nmake: *** [Lib\/plat-linux3] Error 126<\/p>\n<p>\u89e3\u6cd5\uff1a<\/p>\n<pre class=\"prettyprint linenums\" >\n rm -f \/usr\/bin\/python<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8d70\u4e86\u5f88\u591a\u5f2f\u8def\uff0c\u7f51\u4e0a\u7684\u65b9\u6cd5\u53ea\u80fd\u53c2\u8003\uff0c\u81ea\u5df1\u7528\u7684\u65f6\u5019\u6839\u672c\u65e0\u6cd5\u7f16\u8bd1\u8fc7\u53bb\uff0c\u8fd8\u597d\u82b1\u4e86\u4e00\u5929\u534a\u65f6\u95f4\uff0c\u6700\u7ec8\u89e3\u6389\u4e86\u3002 \u603b\u7ed3\u5b9d\u8d35\u7684\u7ecf [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-1681","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/1681","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1681"}],"version-history":[{"count":4,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/1681\/revisions"}],"predecessor-version":[{"id":1685,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/1681\/revisions\/1685"}],"wp:attachment":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1681"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1681"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1681"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}