ubuntu - import zlib error when cross compiling python for arm -


i compiling python arm, on ubuntu in virtual box. after these steps run , place python on machine arm processor. run command "python" in terminal , error says can not import zlib. i've been trying many of solutions online , none have worked me. alas, last hope trying post problem here. able working on target machine when line:

rm -r lib2to3 idlelib lib-tk site-packages config lib-dynload 

is written this:

rm -r lib2to3 idlelib lib-tk site-packages config lib-dynload distutils 

i need distutils because trying install pip on machine. unable though because believe distutils depends on zlib, can't python find zlib after cross compiling target machine. running ubuntu 12.04.5.the following steps taking...

mkdir -p pybuild cd pybuild  # download arm-fsl toolchain git clone git@github.com:embeddedarm/linux-2.6.35.3-imx28.git  # set path variables export path=$path:`pwd`/linux-2.6.35.3-imx28/cross-toolchain/arm-fsl-linux-gnueabi/bin/ export base_python_compilation_path=`pwd`  # sqlite3 headers wget http://backports.debian.org/debian-backports/pool/main/s/sqlite3/libsqlite3-dev_3.7.13-1~bpo60+1_armel.deb ar vx libsqlite3-dev_3.7.13-1~bpo60+1_armel.deb tar xzf data.tar.gz mv usr/* .  # zlib wget http://www.gzip.org/zlib/zlib-1.1.4.tar.gz tar xvf zlib-1.1.4.tar.gz cd zlib-1.1.4 cc=arm-fsl-linux-gnueabi-gcc \ ldshared="arm-fsl-linux-gnueabi-gcc -shared -wl,-soname,libz.so.1" \ ./configure --shared --prefix=$base_python_compilation_path make make install cd ..  # openssl wget https://www.openssl.org/source/openssl-1.0.1i.tar.gz tar xvf openssl-1.0.1i.tar.gz cd openssl-1.0.1i ./configure dist --prefix=$base_python_compilation_path make cc="arm-fsl-linux-gnueabi-gcc" ar="arm-fsl-linux-gnueabi-ar r" ranlib="arm-fsl-linux-gnueabi-ranlib" make install cd ..  # python dependencies wget https://www.python.org/ftp/python/2.7.3/python-2.7.3.tgz tar -xvzf python-2.7.3.tgz cd python-2.7.3  # build host system ./configure make python parser/pgen mv python hostpython mv parser/pgen parser/hostpgen make distclean  # patch wget http://randomsplat.com/wp-content/uploads/2012/10/python-2.7.3-xcompile.patch patch -p1 < python-2.7.3-xcompile.patch  # configure cc=arm-fsl-linux-gnueabi-gcc \ cxx=arm-fsl-linux-gnueabi-g++ \ ar=arm-fsl-linux-gnueabi-ar \ ranlib=arm-fsl-linux-gnueabi-ranlib \ python_xcompile_dependencies_prefix=$base_python_compilation_path \ ./configure --host=arm-linux --build=i686-pc-linux-gnu --prefix=$base_python_compilation_path/tmp  # build make clean make hostpython=./hostpython \ python_xcompile_dependencies_prefix=$base_python_compilation_path \ hostpgen=./parser/hostpgen \ bldshared="arm-fsl-linux-gnueabi-gcc -shared" \ hostarch=arm-linux \ buildarch=x86_64-linux-gnu \ cross_compile=arm-fsl-linux-gnueabi- \ cross_compile_target=yes | tee make.log 2>&1  # "install" make install hostpython=./hostpython \ bldshared="arm-fsl-linux-gnueabi-gcc -shared" \ hostarch=arm-linux \ buildarch=x86_64-linux-gnu \ cross_compile=arm-fsl-linux-gnueabi- \ cross_compile_target=yes prefix=$base_python_compilation_path/python-   2.7.3/_install | tee install.log 2>&1  # create target directory minimal version of installation cd $base_python_compilation_path/python-2.7.3/ rm -r _install_minimal mkdir -p _install_minimal/bin mkdir -p _install_minimal/usr/lib/python2.7 mkdir -p _install_minimal/usr/include  # copy in python binary file cd $base_python_compilation_path/python-2.7.3/ cp _install/bin/python2.7 _install_minimal/bin/python  # bundle lib files zip file, after removing unneeded bits cd $base_python_compilation_path/python-2.7.3/_install/lib/ rm -r python2.7-minimal cp -r python2.7 python2.7-minimal cd python2.7-minimal rm -r lib2to3 idlelib lib-tk site-packages config lib-dynload rm *.doc *.txt rm -r `find -name "test"` zip -r -y python27.zip .  # copy in python library files cd $base_python_compilation_path/python-2.7.3 cp _install/lib/python2.7-minimal/python27.zip _install_minimal/usr/lib/ cp -r _install/lib/python2.7/config _install_minimal/usr/lib/python2.7/ cp -r _install/lib/python2.7/lib-dynload _install_minimal/usr/lib/python2.7/ cp -r _install/lib/python2.7/site-packages _install_minimal/usr/lib/python2.7/ cp -r _install/include/python2.7 _install_minimal/usr/include/ cd _install_minimal rm ../../python.zip zip -r ../../python.zip . cd ../../..  echo "compilation complete (hopefully successfully). now, connect sandisk device's wifi hotspot," echo "and run local ./upload_python.sh script." 

so figured out going wrong. changed

rm -r lib2to3 idlelib lib-tk site-packages config lib-dynload 

to

rm -r site-packages config lib-dynload 

also, whenever running build script, sure remove pybuild directory on beginning of each run. on subsequent runs, pybuild directory still existing, removes .so files reason.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -