4

I'm trying to deploy a python 3 application to an embedded linux (Yocto) machine with armv7-architecture. Because of the limited packages, I am creating a standalone file with cx-freeze on my raspberry pi (which has the same armv7 architecture). Now if I try to run the created binary file on the target machine I get an error which indicates that the source was compiled for another platform:

root@target:/media/sda/dist# ./helloworld
-sh: ./helloworld: No such file or directory

This executable works on the build machine.

I have compared the outputs of the file-command with another application which runs on the target machine:

This is the file which does not work:

root@target:/media/sda/dist# file helloworld
helloworld: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=99b2ae19f1e65dc26b6fd7d8b1dbc83f974830bd, stripped

And this is another binary which does work on the target machine:

root@target:/usr/bin# file demo-application
demo-application: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, BuildID[sha1]=bd6660c43d9e98c59dfa8b16eb26277aa4f19949, stripped

The only difference seems to be the minimum required kernel-version, but uname shows that the actual version is 3.0.35:

root@target:/media/sda/dist# uname -a
Linux Target-Machine 3.0.35-Yocto-21.0-r5061-0-svn2437 #1 PREEMPT Fri Jun 19 21:40:10 CEST 2015 armv7l GNU/Linux

uname output of the raspberry pi build machine:

pi@raspberrypi ~/py/helloworld $ uname -a
Linux raspberrypi 3.18.11-v7+ #781 SMP PREEMPT Tue Apr 21 18:07:59 BST 2015 armv7l GNU/Linux

What am I doing wrong here? It should not be an issue with the actual python code or dependencies, I tried it with a very simple helloworld application with one line of code.

EDIT

Output of ldd command on build machine (exe created with nuitka):

pi@raspberrypi ~/py/helloworld/helloworld.dist $ ldd helloworld.exe
    /usr/lib/arm-linux-gnueabihf/libcofi_rpi.so (0x76faf000)
    libdl.so.2 => /home/pi/py/helloworld/helloworld.dist/./libdl.so.2 (0x76fa4000)
    libpython3.2mu.so.1.0 => /home/pi/py/helloworld/helloworld.dist/./libpython3.2mu.so.1.0 (0x76ccf000)
    libstdc++.so.6 => /home/pi/py/helloworld/helloworld.dist/./libstdc++.so.6 (0x76bfd000)
    libm.so.6 => /home/pi/py/helloworld/helloworld.dist/./libm.so.6 (0x76b8c000)
    libgcc_s.so.1 => /home/pi/py/helloworld/helloworld.dist/./libgcc_s.so.1 (0x76b64000)
    libc.so.6 => /home/pi/py/helloworld/helloworld.dist/./libc.so.6 (0x76a33000)
    /lib/ld-linux-armhf.so.3 (0x76fbc000)
    libz.so.1 => /home/pi/py/helloworld/helloworld.dist/./libz.so.1 (0x76a15000)
    libexpat.so.1 => /home/pi/py/helloworld/helloworld.dist/./libexpat.so.1 (0x769ec000)
    libpthread.so.0 => /home/pi/py/helloworld/helloworld.dist/./libpthread.so.0 (0x769cd000)
    libutil.so.1 => /home/pi/py/helloworld/helloworld.dist/./libutil.so.1 (0x769c2000)

EDIT 2

I tried nuitka to compile the python code and create a standalone application by using:

nuitka --standalone --recurse-all helloworld.py

which produces an executable helloworld.exe file along with all compiled libary files (.so). However, on the target machine, when I try to run this I still get:

root@target:~/helloworld/helloworld.dist# ./helloworld.exe -sh: ./helloworld.exe: No such file or directory

Unfortunately I cannot run the ldd or readelf command on the target machine because their packages are missing.

EDIT 3

It seems that it really lacked some libraries. For experimental purposes, I copied the ld-linux-armhf.so.3 from the raspi to the embedded system and it showed a different error (another library missing). I think another problem is that the raspberry pi uses hardfloat (armhf) whereas the embedded system uses softfloat.. I don't think I can get this to work this way.

EDIT 4 I'm using another platform and os now and everything works so the question is no longer relevant to me.

shofstetter
  • 254
  • 1
  • 10
  • 2
    if you run the ldd command on the binary what is the output? – ojblass Aug 24 '15 at 17:03
  • @ojblass it says: `root@target:/media/sda/dist# ldd helloworld -sh: ldd: command not found` – shofstetter Aug 25 '15 at 06:28
  • @ojblass edited my question – shofstetter Aug 25 '15 at 07:09
  • what kind of partition is sda? Ext(2,3,4), NTFS? If NTFS, it will not work – hellow Aug 25 '15 at 07:22
  • @cookiesoft same error occurs when I try to run it from root-home: `root@target:~/dist# ./helloworld -sh: ./helloworld: No such file or directory ` – shofstetter Aug 25 '15 at 07:29
  • `ldd` on the build host is not very helpful. Find a way to run it on the target system. – Ignacio Vazquez-Abrams Aug 25 '15 at 07:35
  • You didn't answer my question... is it a ntfs or not? What is with the root partition? – hellow Aug 25 '15 at 07:37
  • Does the mentioned libraries exist on the target? Are they included in the library path? Particulary the `libpython3.2mu.so.1.0` looks suspicious. – skyking Aug 25 '15 at 07:44
  • @cookiesoft the sda filesystem type is vfat, I could not determine the filesystem of the root home because `df -T` is an unknown command on the target (it's using busybox). – shofstetter Aug 25 '15 at 08:16
  • @skyking I did a search in the `/usr/lib` of the target and can't find most of these libraries, I'm currently looking for a way to include all these with cx-freeze, does anyone know if this is possible / how to do this? – shofstetter Aug 25 '15 at 08:19
  • Maybe this helps? http://stackoverflow.com/questions/5458048/how-to-make-a-python-script-standalone-executable-to-run-without-any-dependency – hellow Aug 25 '15 at 08:50
  • @cookiesoft thanks, edited my question – shofstetter Aug 25 '15 at 13:41
  • The error in question is typical when you're lacking the correct loader. Do you have '/lib/ld-linux-armhf.so.3' on your target machine? Sure, it could also be that you're lacking other libraries, but the loader is often the main error (and often overlooked). – Anders Aug 31 '15 at 17:42

1 Answers1

0

Run this command on your target machine:

chmod +x helloworld

It makes your file executable.

Rahim Dastar
  • 1,259
  • 1
  • 9
  • 15