Android NDK: how to let gcc to use additional include directories

前端 未结 2 494
走了就别回头了
走了就别回头了 2021-01-07 18:23

A simple question (i am using android NDK r6 with cygwin, but this is a question regarding makefiles and gcc). Suppose that i put under jni/ directory a library under the di

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-07 19:17

    Option 1:

    Add one of the following lines to your Android.mk inside a module of your choice:

       LOCAL_C_INCLUDES := /path/to/your/includes # ignore previous includes
                                                  # OR
       LOCAL_C_INCLUDES += /path/to/your/includes # preserve previous includes
    

    If necessary you could create an environment variable pointing at '/path/to/your/includes' and include it like this:

       LOCAL_C_INCLUDES := $(MYLIB_INCLUDES_PATH) # ignore previous includes
                                                  # OR
       LOCAL_C_INCLUDES += $(MYLIB_INCLUDES_PATH) # preserve previous includes
    

    Option 2:

    1. Copy the complete folder with all header-files in it (mylib) into the 'jni' folder of your project.

    2. Add the following line to your Android.mk inside a module of your choice:

      LOCAL_C_INCLUDES := $(LOCAL_PATH)/mylib
      

      or

      LOCAL_C_INCLUDES += $(LOCAL_PATH)/mylib
      

    Depending on whether there are previous includes or not.

    Option 3:

    Install the CDT plugin for Eclipse and add the absolute path to the 'mylib' directory to the include paths of your project. Here is a great tutorial that shows all the necessary steps.

    http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-development/

提交回复
热议问题