I am developing a 3D App as a native C++ program.
Doing on Eclipse IDE:
* Started the Android application
* launched GDB server on the device
* launched GDB client
Error starting process.
Cannot run program
/app3D/obj/local/armeabi/app_process
: java.io.IOException: error=13, Permission denied
Then, I have changed the permission:
chmod -R 777 /opt/android/android-ndk-r7
chmod -R 777 /home/project/app3D
But the same error persist.
Has someone experienced a similar issue?
That's weird, the executable is normally located in the libs/armeabi folder, not the obj folder...
Editing the build_binary.mk at \android-ndk\build\core\build-binary.mk got rid of this error:
# $(hide) $(call cmd-strip, $(PRIVATE_DST))
ifneq ($(APP_OPTIM),debug)
$(hide) $(call cmd-strip, $(PRIVATE_DST))
endif
And also added to command the following paramenter:
ndk-build NDK_DEBUG=1
Now it works.
Related
The executables and libraries of my program are installed in the directory
BinDir=/data/app/ru.testapp/lib/x86_64/, this directory has execute permission in SELinux.
The rest of the program (additional files) is installed in the Enviroment= /data/user/0/ru.testapp/files/enviroment directory:
bin dev etc lib proc root run sys system usr var.
The Enviroment directory does not have execute rights in SELinux.
I am trying to run the application using proot:
proot\
--link2symlink\
-w /root\
-r $Environment \
-b $BinDir:/bin\
-b $BinDir:/lib \
-b /sys\
-b /system/ \
-b /apex\
-b /proc/ \
-b /dev\
/bin/test
As you can see I "bind" $BinDir to $Enviroment/lib and $Enviroment/bin. In this case, the right to execute SELinux is lost in these directories and I get a "permisiion denied" error. There are definitely no other errors, since under su this whole mechanism works.
What can be done in this situation?
My problem was solved by building proot with the PROOT_UNBUNDLE_LOADER environment variable set so that the loader is in the $BinDir location where SELinux allows execution. In general, the error was with the proot loader.
(Android 10)
I want to execute a simple code in Termux(c++) but every time I get an error:
bash: ./test.cpp: Permission denied
Storage permission is on and gcc is installed.
Do I need root or something else?
As molbdnilo said, you should compile your source file first :
g++ test.cpp
And then execute the binary produced (the default name is a.out)
./a.out
Compile and run it in termux's own directory.
Just start termux:
cd storage/
nano test.cpp
g++ test.cpp "./a.out"
You can run it!
C++ can't do it,you must compile first.
And if it Python,you can add #!/usr/bin/env python to first line,and in shell run chmod 744 xxx.py,and then run ./xxx.py.xxx.py is running.
I never used termux but would Like to suggest U following points for compiling
use chmod 777 test.cpp to grant the permission for read write and execute to all users
use g++ along with gcc to compile C++ files
use sudo apt-get update followed by sudo apt-get install g++
compile using g++ test.cpp -o test
and use ./test to execute the file.
This is how it work in Linux systems.
Cocos2d-x 3.7.1 + ndk r10e project on Mac trying to debug in Eclipse. Days pass and the errors keep coming...
I can build and run using cocos compile and cocos run with -p android -m debug --ndk-mode NDK_DEBUG=1 from the terminal in proj.android.
My app runs Ok (eventually) on my x86 emulator no problem.
Typing 'ndk-gdb' in the terminal from ./proj.android and I get the error
ERROR: Could not find gdb.setup under ./libs/
BUT the file gdb.setup (and gdbserver & libcocos2dcpp.so) can be seen in ./proj.android/libs/x86 !?
My AndroidManifest.xml includes android:debuggable="true"
My jni/Application.mk includes APP_ABI := x86 (only)
If anyone can tell me how I can diagnose or fix this problem then I guess I owe them a beer (in Yorkshire btw)
UPDATE: I have tried running up GDB using the --verbose flag. The output shows
Using gdb setup init: ./libs/armeabi/gdb.setup
Using app out directory: ./obj/local/armeabi
Guess I need to change to settings/init file somewhere??
I ran into the same problem. It seems something changed in recent version of Android Build tools.
The trick is:
ERROR: Could not find gdb.setup under ./libs/
It expects gdb.setup is in the directory libs but NOT libs/armeabi
so the simple workground is to copy gdb.setup and gdbserver from "libs/cpu" to "libs" and it works like a magic!
This is a bug caused by adb from android sdk.Issue 191085: ndk-gdb issue - Could not find gdb.setup under ./libs/ (even though it's there)
Currently previewl channel's adb whose version is 1.0.35 still has the same problem.
Without revert adb to 1.0.31.A simple workaround would be modify ndk-gdb a little: change the line if [ $? = 0 ]; then which is below adb_var_shell BCFILES run-as $PACKAGE_NAME /system/bin/sh -c "ls lib/*.bc" to if [ $? = 1 ]; then
I have created an executable using "include $(BUILD_EXECUTABLE)" command in Android.mk .
My requirement is to execute the above generated executable over the abd shell.
I tried:
Below is my C-Code which is compiled using ndk-build command:
#include <stdio.h>
int main()
{
printf("\n\nHello World\n\n");
return 0;
}
Following is my Android.mk file contents:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := HelloExecutable
LOCAL_SRC_FILES := hello.c
include $(BUILD_EXECUTABLE)
When i execute the command ndk-build the following file is generated:
projectRoot->libs->HelloExecutable
My job is to execute the above generated file on the adb shell. So i first pushed the file onto the sdcard using the following command:
adb push ~/projectRoot->libs->HelloExecutable /sdcard/
Now i switch to adb shell using: $adb shell command(here i'm using an emulator).
Then i change the permissions as: chmod 777 /sdcard/HelloExecutable
Once the above command is executed, i get the executing permissions for my HelloExecutable file.
Then change the current working directory to sdcard. i.e. cd /sdcard/
Now when i try to execute the above file i get the following error:
# ./HelloExecutable
./HelloExecutable: permission denied
To perform the above i'm using an emulator. So can someone please tell the reason for the above error??
I kindly request the viewers to address the above problem. Waiting for your answers. Thanks in advance.
Check if your SD card is mounted with noexec option. Try copying your file to another partition like /data and execute it from there.
I am following the steps on http://developer.android.com/sdk/ndk/overview.html to build the hello-jni sample, however when I get to Step 2 to run
cd $NDK-ROOT/samples/hello-jni
$NDK-ROOT/ndk-build
in the Cygwin command prompt, I receive the following error messages:
/bin/sh: -c: line 0: unexpected EOF while looking for matching `''
/bin/sh: -c: line 1: syntax error: unexpected end of file
Android NDK: Host awk tool is outdated. Please define HOST_AWK to point to Gawk
or Nawk !
I have Cygwin 1.7.9, Gnu Make 3.8.2, and Gawk 3.1.8 on my Windows machine, along with the r5b release of the Android NDK.
I also have set the HOST_AWK environment variable, which points to my Gawk folder.
Unfortunatley the sample cannot run successfully without this step, (if I run hello-jni, I immediately receive an UnsatisfiedLinkError exception).
Below is the portion of the init.mk file on my machine (found in NDK_ROOT/build/core) which creates this error:
# Location of all awk scripts we use
BUILD_AWK := $(NDK_ROOT)/build/awk
AWK_TEST := $(shell $(HOST_AWK) -f $(BUILD_AWK)/check-awk.awk)
$(call ndk_log,Host awk test returned: $(AWK_TEST))
ifneq ($(AWK_TEST),Pass)
$(call __ndk_info,Host awk tool is outdated. Please define HOST_AWK to point to Gawk or Nawk !)
$(call __ndk_error,Aborting.)
endif
Thank-you for your help
Try updating your awk tool. Seems to an an outdated version (perhaps). Also ensure that NDK root is defined to where you have your NDK source and ensure that your awk tool is located in the build directory of your NDK Source.
NDK_ROOT
Try settings this environment variable to where your NDK root is. Whenever this is defined (Typically at the top)
Instead of HOST_AWK=gawk.exe, just do HOST_AWK=gawk
It turns out there was an apostrophe in my HOST_AWK path, which was causing the problem.
reference
https://stackoverflow.com/q/8121153/411522
mine worked fine now.what to do is: just rename the prebuilt awk in ndk