Python – Cross-compiling Python

cross-compilationpython

I am using an evaluation board with an ARM926EJ-S running Openembedded and I want to install python on it.

I successfully cross-compiled python 2.7.13 on my Fedora 25 with the linaro toolchain (releases.linaro.org/components/toolchain/binaries/6.2-2016.11/) like this :

CONFIG_SITE=config.site ./configure --build=x86_64-linux-gnu --host=arm-linux-gnueabihf --disable-ipv6 --enable-unicode=ucs4

I had to do a config.site because during the compilation it asked me to precise :

ac_cv_file__dev_ptmx=no/yes
ac_cv_file__dev_ptc=no/yes

And I put "no" to both of them like this guy did : datko.net/2013/05/10/cross-compiling-python-3-3-1-for-beaglebone-arm-angstrom/

Then I test to add :

--host=arm-elf-linux

Because it worked for another lib (pjsip), but unfortunately it didn't worked so I found this solution :

--host=arm-unknown-linux-gnueabihf

Here : github.com/jedisct1/libsodium/issues/274

And this was for an error during the configuration asking me to do so :

--desable-ipv6

Then the configuration went well, so the make.
To do the make install, because I had to install it on my board, I did :

make install DESTDIR=root@IP_ADRESS

This worked too, python is installed in root@IP_ADRESS/usr/local/lib/python2.7.

But I can't find it in my board, nor launch the python shell.

So I try this :

export LD_LIBRARY_PATH="/lib:/usr/lib:/usr/local/lib"

Like answered here : stackoverflow.com/questions/4743233/is-usr-local-lib-searched-for-shared-libraries

This doesn't change anything, and I figure out that /usr/local/lib does not exist… And I found that my pjsip lib is not installed too…

Do you know where my libs went ? And how I can use them ?

Thank you !

EDIT :

Found the solution, in fact when you do :

make install DESTDIR=root@IP_ADRESS

It is not going to install it to root@IP_ADRESS, but it is creating a folder named "root@IP_ADRESS"…

So I tar.bz2 all the files contained in this folder, send them with scp on my board and copy all the folders and files in the /usr/ of my board.

But python is not working, when I try to launch it:

~# python
-sh: /usr/bin/python: cannot execute binary file

Is it because during the config part, the –host is not the good one?

Best Answer

I found the solution. The board I use is the TMDSLCDK138 integrating an OMAPL138 (ARM926EJ-S + DSP).

For those trying to cross-compile Pyhton 2.7 for this board running the Arago SDK here is the way ! I am working on Ubuntu 16.04.

First install the Arago toolchain :

NOT THIS ONE : http://software-dl.ti.com/sdoemb/sdoemb_public_sw/arago_toolchain/2011_09/index_FDS.html (Because it is DEPRECATED !!)

But the one in the mcsdk_1_01_00_02_setuplinux.bin !

wget http://software-dl.ti.com/sdoemb/sdoemb_public_sw/mcsdk/latest1/exports/mcsdk_1_01_00_02_setuplinux.bin
chmod +x mcsdk_1_01_00_02_setuplinux.bin
sudo ./mcsdk_1_01_00_02_setuplinux.bin

I install it in /opt/ti/

Then :

cd /opt/ti/mcsdk_1_01_00_02
chmod +x linux-devkit.sh
sudo ./linux-devkit.sh

It is going to ask you where you want to install it, I kept /usr/local/arago.2013-05/

Now :

cd /usr/local/arago-2013.05/
. ./environment-setup

Normally your shell is going to "transform" and your command lines are performing with :

[linux-devkit]:/usr/local/arago-2013.05/>

Ok, here you have finished installing the GOOD Arago toolchain.

Now cross-compiling and installing Python :

I did all the others commands in this linux-devkit shell.

wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tar.xz
tar -Jxvf Python-2.7.13.tar.xz
cd Python-2.7.13/

Now create a file named config.site (because if you don't you get an error asking you to do so) :

touch config.site
gedit config.site

Add those two lines in this file :

ac_cv_file__dev_ptmx=no
ac_cv_file__dev_ptc=no

Now you can do the ./configure like so :

CONFIG_SITE=config.site ./configure --host=arm-arago-linux --prefix=/home/YOUR_USER/MY_BOARD_python --build=x86_64-linux-gnu --disable-ipv6
make
make install

Now you just have to compress your MY_BOARD_python folder, scp it to your board with :

tar -jcvf MY_BOARD_python.tar.bz2 MY_BOARD_python/
scp MY_BOARD_python.tar.bz2 root@IP_ADRESS:~/

Now on your board :

tar -jxvf MY_BOARD_python.tar.bz2
cp -R MY_BOARD_python/* /usr/

And now if you type Python :

root@omapl138-lcdk:~# python
Python 2.7.13 (default, Feb 23 2017, 16:37:33) 
[GCC 4.5.3 20110311 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> HURAYY!!

Hop this is going to help !

Related Question