Android ndk compilation getevent
I extracted getevent. c getevent. h from the android source code and put it in a directory for jni compilation and testing.
Added Android. mk content as follows:
LOCAL_PATH: = $ (call my-dir)
Include $ (CLEAR_VARS)
LOCAL_MODULE: = GetEvent
LOCAL_SRC_FILES: = getevent. c
Include $ (BUILD_SHARED_LIBRARY)
Go to the source code directory and manually compile:
Ndk-build V = 1 2> & 1 | tee log.txt
Log.txt
A lot of errors will occur during compilation:
/Opt/android-ndk-r10d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc-MMD-MP-MF. /obj/local/armeabi/objs/GetEvent/getevent. o. d-fpic-ffunction-sections-funwind-tables-fstack-protector-no-canonical-prefixes-march = armv5te-mtune = xscale-msoft-float-mthumb-OS-g- DNDEBUG-fomit-frame-pointer-fno-strict-aliasing-finline-limit = 64-Ijni-DANDROID-Wa, -- noexecstack-Wformat-I/opt/android-ndk-r10d/platforms/android-3/arch-arm/usr/include-c jni/getevent. c-o. /obj/local/armeabi/objs/GetEvent/getevent. o
In file encoded ded from jni/getevent. c: 14: 0:
Jni/getevent. h: 12: 15: error: 'input _ PROP_POINTER 'undeclared here (not in a function)
LABEL (INPUT_PROP_POINTER ),
^
Jni/getevent. h: 8: 38: note: in definition of macro 'label'
# Define LABEL (constant) {# constant, constant}
^
Jni/getevent. h: 13: 15: error: 'input _ PROP_DIRECT 'undeclared here (not in a function)
LABEL (INPUT_PROP_DIRECT ),
^
Jni/getevent. h: 8: 38: note: in definition of macro 'label'
# Define LABEL (constant) {# constant, constant}
^
Jni/getevent. h: 14: 15: error: 'input _ PROP_BUTTONPAD 'undeclared here (not in a function)
LABEL (INPUT_PROP_BUTTONPAD ),
^
Jni/getevent. h: 8: 38: note: in definition of macro 'label'
# Define LABEL (constant) {# constant, constant}
.................................
There is no error in using the cross compiler of helper2416 to compile getevent. c separately, so the problem must be in the android compiler.
Carefully checked and found
/Opt/android-ndk-r10d/platforms/android-3 directory does not have the linux/input. h header file (getevent. h requires this file header)
Instead there is under/opt/android-ndk-r10d/platforms/android-21, so it is-I directory error.
Manually execute the compilation command:
/Opt/android-ndk-r10d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc-MMD-MP-MF. /obj/local/armeabi/objs/GetEvent/getevent. o. d-fpic-ffunction-sections-funwind-tables-fstack-protector-no-canonical-prefixes-march = armv5te-mtune = xscale-msoft-float-mthumb-OS-g- DNDEBUG-fomit-frame-pointer-fno-strict-aliasing-finline-limit = 64-Ijni-DANDROID-Wa, -- noexecstack-Wformat-I/opt/android-ndk-r10d/platforms/android-21/arch-arm/usr/include-c jni/getevent. c-o. /obj/local/armeabi/objs/GetEvent/getevent. o
The compilation was successful and confirmed my opinion.
Solution:
Add the Application. mk file to the source code directory.
Content is
APP_PLATFORM: = android-21
Author: handsome, dare not go out, programmer group: 31843264