Cygwin中的Android NDK Build错误

时间:2013-07-20 01:47:20

标签: android android-ndk cygwin

我正在为一个Android应用程序配置NDK,该应用程序在其标题中使用了linux / input.h文件 - #include。问题是当我调用ndk-build时,它会产生一个错误,这基本上意味着它找不到linux / input.h。现在,cygwin不包含linux目录,这可能就是为什么会出现这个错误,但ndk确实包含它 - android-ndk-r8e \ platforms \ android-14 \ arch-x86 \ usr \ include \ linux \ input.h - 不应该在这里进行ndk-build搜索吗?为了给出一些更多的上下文,我试图编译描述here的EventInjector库,其他人似乎让它工作,这意味着它必须以某种方式可能。

1 个答案:

答案 0 :(得分:1)

请按照以下说明操作:

  1. 在Android.mk

    LOCAL_PATH := $(call my-dir)
    include $(CLEAR_VARS)
    TARGET_PLATFORM := android-8
    LOCAL_MODULE    := your_lib
    LOCAL_SRC_FILES := my_file.c
    LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
    include $(BUILD_SHARED_LIBRARY)</li>
    
         

   your_lib 将是您图书馆的名称,您可以写任何名称

my_file.c 将是您在JNI文件夹中出现的源文件名

Right click on project
Choose Properties>Builders
Click on New...
Select Program, then Ok

In main tab:
Give your Builder a suitable name, eg. "NDK"
For Location, click on Browse file system>select your ndk-build.cmd,
eg. C:\android-ndk-r8-windows\android-ndk-r8\ndk-build.cmd (My NDK path)

Below there will be Working Directory:
Click on: Browse workspace - choose your project,
eg. ${workspace_loc:/Test} (My project 'Test')

Click on **Refresh Tab**
Select **Specific Resources** radio button
Click on **Specify Resources..**
Select libs folder from your project
Now click on **Build Options** Tab
Check:
After a Clean
During manual builds
During auto builds
Specify working set of relevant resources 
Click on **Specify Resources...**
Select JNI folder of your project
Click Apply...Ok 

现在清理并构建...然后刷新

你将在libs&gt; armeabi中获得your_lib.so libs&gt; armeabi&gt; your_lib.so这个结构会自动创建....