2

I configure ndk with eclipse in order to build my c++ code automatically. But i have two external .so file inside libs folder. Everytime, eclipse will delete these external .so file automatically when build project. Is it possible to tell eclipse not delete these external file.

flyzhao
  • 348
  • 4
  • 15
  • Is the 'libs' folder an output folder? If so, that sounds wrong. – nitind Jun 24 '13 at 13:46
  • Yes, it seems i need write a script to copy external .so file into this found when build – flyzhao Jun 25 '13 at 02:48
  • This actually happened to me recently while building. It never used to do this however. I had been doing this for some time previously. Not sure why now it decides to delete things all of a sudden. There must be a setting somewhere. – Jay Snayder Aug 06 '14 at 15:53

2 Answers2

1

The solution is here.

To summarize (and complement):

  • Copy your external (e.g., libexternal.so) library (or libraries) to another folder inside your 'jni' folder; for example 'myproject/jni/prebuilt'.

  • Add the following block to your existing 'jni/Android.mk' (one block for each external library):

    include $(CLEAR_VARS)
    LOCAL_MODULE := libexternal
    LOCAL_SRC_FILES := prebuilt/libexternal.so
    include $(PREBUILT_SHARED_LIBRARY)
    
  • Add 'libexternal' to 'APP_MODULES' in your existing 'jni/Application.mk'. 'APP_MODULES' should already list your JNI module (e.g., 'myjnimodule'):

    APP_MODULES := libexternal myjnimodule
    
  • Confirm that the following block exists in 'jni/Application.mk'. Use the appropriate target architecture(s):

    APP_ABI := armeabi-v7a
    

The result is that, as part of the invocation to 'ndk-build', the external library is copied to your 'myproject/libs/armeabi-v7a' folder.

Community
  • 1
  • 1
John Doedoe
  • 3,423
  • 1
  • 12
  • 8
1

The solution given by John Doedoe led me to another possibility, specific to Eclipse (tested on Mars 1 version):

  • Right click on your project in the project explorer.
  • Go into properties.
  • Go into "C/C++ Build".
  • Go into the "Builder Settings" tab.
  • Uncheck "Use default build command".
  • In the "Build command" text box type your target, e.g.: ndk-build APP_ABI="armeabi-v7a"
  • Apply / Ok

enter image description here

This will avoid changing behavior on a build machine for instance.

Romano
  • 445
  • 1
  • 8
  • 20