Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"No such file or directory" trying to execute linux binary on Android device

I built a native linux ARM binary using the Android GCC toolchain (plain linux, no android or NDK).

I connected, from my PC, via adb shell, to a tablet running Android 4. I "adb push"'ed that binary into /system/bin on that device, hoping I would get it to execute there. I marked it executable with chmod 777.

If I try to execute it, I would get "No such file or directory".

Further info: The little program uses fc and fm libs. Since the ARM toolchain does not appear to have crt1, which, from an example I found, normally contains the startup code, we searched through files containing it in the android build, found crtbegin_dynamic and crtend_dynamic, but for _static equivalent, one of the pair was missing, so I did not pass -static to GCC. It was built with "-nostdlib".

What could be the problem(s)?

like image 678
user1847129 Avatar asked Nov 27 '12 10:11

user1847129


People also ask

How do I fix No such file or directory in Linux?

First, make sure you execute the program with the correct path. If you make a typo on the directory or file name, you will get this error or give the wrong path. If you are executing the file with a relative path ( ../../file ), try executing with the absolute path ( /path/to/file ) instead.

Why do I keep getting no such file or directory?

log No such file or directory” the problem is most likely on the client side. In most cases, this simply indicates that the file or folder specified was a top-level item selected in the backup schedule and it did not exist at the time the backup ran.

What do you do when it says no such file or directory?

The error "FileNotFoundError: [Errno 2] No such file or directory" is telling you that there is no file of that name in the working directory. So, try using the exact, or absolute path. In the above code, all of the information needed to locate the file is contained in the path string - absolute path.


2 Answers

If you are working on a 64-bit platform like Ubuntu 64, then this tip may help you solve the issue. Just try to get the i386 32-bit compatibility libraries installed simply with apt-get:

sudo apt-get install ia32-libs

It worked great for me. Let me know if you are stuck in same trouble.

For Ubuntu 13.10 or greater

As aditya said in the comments to this answer:

As of Ubuntu 13.10, one has to run this now: sudo apt-get install lib32z1, you may need to get the C++ stdlibs too, with this: sudo apt-get install lib32ncurses5 lib32stdc++6

like image 108
EthanL Avatar answered Oct 21 '22 17:10

EthanL


To amend aditya's comment above, you can also use the following for the C++ stdlibs in Ubuntu 13.10:

sudo apt-get install lib32ncurses5 libstdc++6:i386
like image 2
Shanker Kaura Avatar answered Oct 21 '22 18:10

Shanker Kaura