CentOS 编译安装 PyCrypto
2015-05-18 20:41
281 查看
转载自:http://bugcharmer.blogspot.com/2012/07/building-pycrypto-on-amazon-ec2.html
$ sudo yum install make
That was easy.
$ bunzip2 gmp-5.0.5.tar.bz2
$ cd gmp-5.0.5
$ sudo ./configure
$ sudo make
$ sudo make check
$ sudo make install
$ cd
Still not too bad.
$ bunzip mpir-2.5.1.tar.bz2
$ cd mpir-2.5.1
$ sudo ./configure
$ sudo make
$ sudo make check
$ sudo make install
$ cd
Everything worked up through here.
Intermission
There are two problems you’ll run into if you try to build PyCrypto at this point: errors from missing header files and, once you resolve those, runtime errors complaining about an undefined symbol for rpl_malloc. Let’s fix that.
Easy fix.
$ tar xzvf pycrypto-2.6.tar.gz
$ cd pycrypto-2.6
Find the this section of the script (I added line numbers):
: if test $ac_cv_func_malloc_0_nonnull = yes; then:
:
: $as_echo "#define HAVE MALLOC 1" >> confdefs.h
:
: else
: $as_echo "define HAVE_MALLOC 0" >> confdefs.h
:
: case " $LIBOBJS " in
: *" malloc.$ac_objext "* ) ;;
: *) LIBOBJS = "$LIBOBJS malloc.$ac_objext"
: ;;
: esac
:
;
: $as_echo "define malloc rpl_malloc" >>confdefs.h
:
: fi
Keep line 3867, but comment out the rest. Save and exit.
or
$ export ac_cv_func_malloc_0_nonnull=yes
The problem is that when you try to build PyCrypto, autotools thinks that we’re using rpl_malloc instead of malloc. I’m not sure how to fix this problem the right way, but this hack will get rid of the check and just have it use malloc. If someone knows the right way to fix this, please say something in the comments and I’ll update this post.
否则会有如下错误:
ImportError: /usr/local/lib/python2.6/dist-packages/pycrypto-2.6-py2.6-linux-x86_64.egg/Crypto/Cipher/_AES.so: undefined symbol: rpl_malloc
$ sudo python.setup.py install
>>> from Crypto.Cipher import AES
If this works, you should be good to go.
If it fails, you did something wrong. You can either rm -r pycrypto-2.6 and re-extract the archive or just rm -r the build folder then grep for anything that says “rpl_malloc” and comment it out. Also edit config.status and change ‘D[“HAVE_MALLOC”]=” 0”’ to say ‘=” 1”’. This is what I did the first time, but when I decided to write this up I started over to try to get it right from the start.
Step 1 - Install gcc/make
$ sudo yum install gcc$ sudo yum install make
That was easy.
Step 2 - Install the GNU MP Arithmetic Library
$ wget ftp://ftp.gmplib.org/pub/gmp-5.0.5/gmp-5.0.5.tar.bz2$ bunzip2 gmp-5.0.5.tar.bz2
$ cd gmp-5.0.5
$ sudo ./configure
$ sudo make
$ sudo make check
$ sudo make install
$ cd
Still not too bad.
Step 3 - Install MPIR
$ wget http://www.mpir.org/mpir-2.5.1.tar.bz2$ bunzip mpir-2.5.1.tar.bz2
$ cd mpir-2.5.1
$ sudo ./configure
$ sudo make
$ sudo make check
$ sudo make install
$ cd
Everything worked up through here.
Intermission
There are two problems you’ll run into if you try to build PyCrypto at this point: errors from missing header files and, once you resolve those, runtime errors complaining about an undefined symbol for rpl_malloc. Let’s fix that.
Step 4 - Install the Python development headers
$ sudo yum install python-develEasy fix.
Step 5 - Download PyCrypto
$ wget http://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-2.6.tar.gz$ tar xzvf pycrypto-2.6.tar.gz
$ cd pycrypto-2.6
Step 6 - Edit the configure script
$ [favorite editor] configureFind the this section of the script (I added line numbers):
: if test $ac_cv_func_malloc_0_nonnull = yes; then:
:
: $as_echo "#define HAVE MALLOC 1" >> confdefs.h
:
: else
: $as_echo "define HAVE_MALLOC 0" >> confdefs.h
:
: case " $LIBOBJS " in
: *" malloc.$ac_objext "* ) ;;
: *) LIBOBJS = "$LIBOBJS malloc.$ac_objext"
: ;;
: esac
:
;
: $as_echo "define malloc rpl_malloc" >>confdefs.h
:
: fi
Keep line 3867, but comment out the rest. Save and exit.
or
$ export ac_cv_func_malloc_0_nonnull=yes
The problem is that when you try to build PyCrypto, autotools thinks that we’re using rpl_malloc instead of malloc. I’m not sure how to fix this problem the right way, but this hack will get rid of the check and just have it use malloc. If someone knows the right way to fix this, please say something in the comments and I’ll update this post.
否则会有如下错误:
ImportError: /usr/local/lib/python2.6/dist-packages/pycrypto-2.6-py2.6-linux-x86_64.egg/Crypto/Cipher/_AES.so: undefined symbol: rpl_malloc
Step 7 - Build PyCrypto
$ python setup.py build$ sudo python.setup.py install
Step 8 - Test PyCrypto
$ python>>> from Crypto.Cipher import AES
If this works, you should be good to go.
If it fails, you did something wrong. You can either rm -r pycrypto-2.6 and re-extract the archive or just rm -r the build folder then grep for anything that says “rpl_malloc” and comment it out. Also edit config.status and change ‘D[“HAVE_MALLOC”]=” 0”’ to say ‘=” 1”’. This is what I did the first time, but when I decided to write this up I started over to try to get it right from the start.
相关文章推荐
- 手把手教你在centos下编译安装配置高性能web服务器环境nginx+php(fast-cgi)+mysql等/适合小内存vps使用
- CentOS 6.6 下源码编译安装MySQL 5.7.5
- LNMP环境编译安装备忘-centos6.2
- 转:在CentOS下编译安装GCC
- centos7 编译安装php5.6.27
- CentOS 6.5系统安装编译安装MySQL 5.6详细过程
- CentOS上编译安装OpenCV-2.3.1与ffmpeg-2.1.2
- centos 7.0 编译安装php 5.6.7
- CentOS编译安装nodejs
- CentOS 编译 nginx+php+mysql 安装手记
- centos 编译 安装 protobuf
- centos6.5下编译安装mariadb-10.0.20
- centos手动编译安装apache、php、mysql
- hadoop学习第二节:Centos7源码编译安装Hadoop2.2.0
- Nginx 1.5.2 + PHP 5.5.1 + MySQL 5.6.10 在 CentOS 下的编译安装
- CentOS 6.3下编译安装Ruby 2.0
- CentOS编译安装VIM7.4支持Python
- CentOS6.4下编译安装配置nginx1.2.3+php5.3.16+mysql5.5.27+memcached1.4.5
- Centos 下编译安装Redis
- centos编译安装PHP