2016-06-21 10 views
0

Ich versuche nur ein ndk-build für ein einfaches Hallo-Programm zu tun.ndk-build ausführbare Datei nicht als ausführbar erkannt

Android.mk Datei:

LOCAL_PATH:= $(call my-dir) # Get the local path of the project. 
include $(CLEAR_VARS) # Clear all the variables with a prefix "LOCAL_" 

LOCAL_SRC_FILES:=hello.cpp # Indicate the source code. 
LOCAL_MODULE:= hello # The name of the binary. 
LOCAL_ARM_MODE := arm 
include $(BUILD_EXECUTABLE) # Tell ndk-build that we want to build a native executable. 

Application.mk Datei:

APP_ABI := armeabi-v7a # Define the target architecture to be ARM. 
APP_STL := gnustl_static 
#APP_STL := gnustl_static 
APP_CPPFLAGS := -frtti -fexceptions # This is the place you enable exception. 
APP_PLATFORM = android-19 

Quelldatei (hello.cpp):

#include <iostream> 

int main(int argc, char* argv[]) 
{ 
    std::cout<<"Hello from world!"<<std::endl; 
    for(int i=0; i<argc; ++i) 
     std::cout<<"Arg "<<i<<" is: "<<argv[i]<<std::endl; 
    return 0; 
} 

NDK-build ist Erfolg:

[armeabi-v7a] Compile++ arm : hello <= hello.cpp 
[armeabi-v7a] Executable  : hello 
[armeabi-v7a] Install  : hello => libs/armeabi-v7a/hello 

Aber nachdem ich diese an den Emulator geschoben und versuchen, auszuführen, habe ich diesen Fehler: /system/bin/sh: ./hello: nicht ausführbar: 32-Bit-ELF-Datei

prüfen mit Datei Befehl und es zeigt als: file libs/armeabi-v7a/hallo libs/armeabi-v7a/hallo: ELF 32-Bit LSB gemeinsames Objekt, ARM, EABI5 Version 1 (SYSV), dynamisch verknüpft, Interpreter/System/bin/Linker, gestrippt

Chck mit readelf: readelf --file-header libs/armeabi-V7A/hallo

ELF Header: 
    Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
    Class:        ELF32 
    Data:        2's complement, little endian 
    Version:       1 (current) 
    OS/ABI:       UNIX - System V 
    ABI Version:      0 
    Type:        DYN (Shared object file) 
    Machine:       ARM 
    Version:       0x1 
    Entry point address:    0x3898 
    Start of program headers:   52 (bytes into file) 
    Start of section headers:   205324 (bytes into file) 
    Flags:        0x5000200, Version5 EABI, soft-float ABI 
    Size of this header:    52 (bytes) 
    Size of program headers:   32 (bytes) 
    Number of program headers:   8 
    Size of section headers:   40 (bytes) 
    Number of section headers:   26 
    Section header string table index: 25 

Also, was ist los mit meiner Einstellung? Kann einfach nicht herausfinden warum. Vielen Dank im Voraus.

Antwort

2

Ein Emulator kann so konfiguriert werden, dass nur eine Art von CPU ABI ausgeführt wird. Es ist möglich, dass Ihr Emulator auf x86 gesetzt wurde. Stellen Sie sicher, dass die ABI, die Sie in Ihrer Application.mk erstellen, mit der in Ihrem Emulator konfigurierten ABI übereinstimmt. Zum Beispiel, wenn Ihr Emulator läuft x86:

enter image description here

Stellen Sie sicher, Ihre Application.mk Datei auch auf den gleichen Wert gesetzt wird:

APP_ABI := x86  
0

Scheint, es ist ein Problem im Zusammenhang mit Emulator. Pushed dies auf ein Android-Gerät und es funktioniert.