一.准备工作: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#
bzip2库pc版:
1. cd bzip2-1.0.6/
2. make
3. make install PREFIX=/cwf/ccc/python/pc_pythoninstall
编译pc版python:
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、