Android ndk compilation getevent

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.