I want to run hello world
written on C++ and compiled with Android toolchain 9
, but I faced with issue: by default I have no permissions to launch it and I can't change permissions using chmod`.
I used Android 2.3.3 - Api Level 10
Application was compiled by cross compiler for API level 9
Procedure:
Compile application:
~/toolchain_andr9/bin/ arm-linux-androideabi-g++ helloworld.cpp
Then send application to SDCARD on the emulator:
>adb push a.out /mnt/sdcard
then go to SHELL and try to run a.out
:
>adb shell
>
>/mnt/sdcard/a.out
And result is:
>`/mnt/sdcard/a.out: permission denied`
command ls -l
shows rights for a.out
:
>`----rwxr-x system sdcard_rw 863656 2012-04-12 22:42 a.out`
I tried to change permissions:
>chmod 777 /mnt/sdcard/a.out
But rights don't change:
>`----rwxr-x system sdcard_rw 863656 2012-04-12 22:42 a.out`
I think I have left some important thing using android.
Could anybody help me and give me a way how to run application in `Android SHELL?
Thanks a lot.
P.S. sorry for my English =)
Download the NDK and build toolsThe Android Native Development Kit (NDK): a toolset that allows you to use C and C++ code with Android, and provides platform libraries that allow you to manage native activities and access physical device components, such as sensors and touch input.
To Install and Use C/C++ compiler in Termux (in Termux clang is the C/C++ compiler) , Download & Install Termux from : Play Store. After Installing execute this command pkg install clang. After Successfully installing clang you can compile C/C++ scripts.
Solution 1. You can use the design and GUI of your app and the internal model code if it is well crafted. But you have to re create the GUI in the native Android IDE and than transfer your code into the handler functions. If you want to use one code base for different target than may Xamarin an interesting tool.
By default, the SD card is mounted with option noexec
, that disallows the execution of any file on the card, no matter what it's permissions(even -rwxrwxrwx
), so you need to move the file to another location and then execute it.
The easiest is to move the file to /data/local/tmp/
and execute it using the full path (usual POSIX PATH semantics).
> adb push a.out /data/local/tmp/a.out
> adb shell
> chmod 755 /data/local/tmp/a.out
> /data/local/tmp/a.out
This does not require root access and survives reboot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With