python和其第三方库交叉编译过程

一.准备工作:pc版的python和第三方库

 

Ubuntu环境如下:

root@cwf-virtual-machine:/cwf/ccc/python# ls -al /usr/bin/gcc

lrwxrwxrwx 1 root root 7 Dec  8 11:44 /usr/bin/gcc -> gcc-4.6

root@cwf-virtual-machine:/cwf/ccc/python# ls -al /usr/bin/g++

lrwxrwxrwx 1 root root 7 Mar 14  2012 /usr/bin/g++ -> g++-4.6

root@cwf-virtual-machine:/cwf/ccc/python# ls -al /usr/bin/gfortran

lrwxrwxrwx 1 root root 12 Mar 14  2012 /usr/bin/gfortran -> gfortran-4.6

root@cwf-virtual-machine:/cwf/ccc/python#

 

bzip2pc版:

1. cd bzip2-1.0.6/

2. make

3. make install PREFIX=/cwf/ccc/python/pc_pythoninstall

 

编译pcpython

1. cd /cwf/ccc/python/pc_pythoninstall/Python-2.7.10

2. ./configure --prefix=/cwf/ccc/python/pc_pythoninstall

3.make

4.make install

5. 验证bz2

/cwf/ccc/python/pc_pythoninstall/bin/python

>>> import bz2

>>>

 

用以上python编译pc版的第三方库:

Numpy库:

Numpy目录下:

/cwf/ccc/python/pc_pythoninstall/bin/python setup.py config_fc --help-fcompiler

 

/cwf/ccc/python/numpy/numpy-1.10.0/numpy/distutils/fcompiler# vi gnu.py

 

1. cd numpy-1.10.0

2. cd /cwf/ccc/python/numpy/numpy-1.10.0/numpy/distutils/fcompiler

Vi gun.py

def get_flags_opt(self):

opt = ['-O2 -march=x86-64 -DMS_WIN64 -mtune=generic -msse2']

改为

opt = ['-O2']

3. /cwf/ccc/python/pc_pythoninstall/bin/python setup.py config_fc --help-fcompiler

 

 

 

4. /cwf/ccc/python/pc_pythoninstall/bin/python setup.py install --prefix=/cwf/ccc/python/pc_pythoninstall

5.验证

/cwf/ccc/python/pc_pythoninstall/bin/python

>>> import numpy

>>>

 

zope库:

1. cd zope.interface-3.8.0

2. /cwf/ccc/python/pc_pythoninstall/bin/python setup.py install --prefix=/cwf/ccc/python/pc_pythoninstall

3.验证

/cwf/ccc/python/pc_pythoninstall/bin/python

>>> import zope

>>>

 

 

Twisted库:

1. cd Twisted-15.2.1

2. /cwf/ccc/python/pc_pythoninstall/bin/python setup.py install --prefix=/cwf/ccc/python/pc_pythoninstall

3. 验证

/cwf/ccc/python/pc_pythoninstall/bin/python

>>> import twisted

>>>

 

Setuptools库:

1. cd setuptools-0.6c11

2. /cwf/ccc/python/pc_pythoninstall/bin/python setup.py install --prefix=/cwf/ccc/python/pc_pythoninstall

3. 验证

/cwf/ccc/python/pc_pythoninstall/bin/python

>>> import setuptools

>>>

 

Lapack库:

1. cd lapack-3.6.1

2. cp make.inc.example make.inc

3. 编辑makefile

lib: lapacklib tmglib

#lib: blaslib variants lapacklib tmglib

改为:

#lib: lapacklib tmglib

lib: blaslib variants lapacklib tmglib

4. make blaslib

5. make lapacklib

6. cp liblapack.a librefblas.a /cwf/ccc/python/pc_pythoninstall/lib/

 

Scipy库:

1. export BLAS=/cwf/ccc/python/pc_pythoninstall/lib/librefblas.a

2. export LAPACK=/cwf/ccc/python/pc_pythoninstall/lib/liblapack.a

3. /cwf/ccc/python/pc_pythoninstall/bin/python setup.py install --prefix=/cwf/ccc/python/pc_pythoninstall

4. 验证

/cwf/ccc/python/pc_pythoninstall/bin/python

>>> import scipy.io as io

>>>

 

Scikit库:

1. cd scikit-learn-0.18.1

2. /cwf/ccc/python/pc_pythoninstall/bin/python setup.py install --prefix=/cwf/ccc/python/pc_pythoninstall

3. 验证

/cwf/ccc/python/pc_pythoninstall/bin/python

>>> import sklearn

>>>

 

 

二.交叉编译第三方库

g++gcc

  • 0
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值