0

I would like to statically link OpenCV(2.4.3.2) to my project. Right now my Android.mk looks like this

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on

include /Users/jamiematthews/Documents/Android-Projects/OpenCV-2.4.3-android-sdk/sdk/native/jni/OpenCV.mk

LOCAL_MODULE    := jni_part
LOCAL_SRC_FILES := jni_part.cpp
LOCAL_LDLIBS +=  -llog -ldl
LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -llog 
include $(BUILD_SHARED_LIBRARY)

Which throws the errors:

Android NDK: ERROR:/Users/jamiematthews/Documents/workspace/AuthentiGuard/jni/Android.mk:on: LOCAL_SRC_FILES points to a missing file    
/Users/jamiematthews/Documents/android-ndk-r8d/build/core/prebuilt-library.mk:43: *** Android NDK: Aborting    .  Stop.
Android NDK: Check that /Users/jamiematthews/Documents/Android-Projects/OpenCV-2.4.3-android-sdk/sdk/native/jni/../libs/mips/libon.so exists  or that its path is correct

Anyone know what "LOCAL_SRC_FILES points to a missing file" could mean?

PS if I remove the lines

OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on

it compiles fine, but then I cant statically link

2 Answers 2

1

Found the solution. Believe it or not it was an issue with Application.mk, not Android.mk. I had set

APP_ABI := all

Previously, and not even considered that it could effect the build process of this statically. I ended up changing it to

APP_ABI := armeabi-v7a

And now, everything works fine. Note that I ended up not needing OPENCV_CAMERA_MODULES:=on, I believe that is only if you are calling the camera from JNI, which I am not

1
  • this solution not work for me though my application.mk and android.mk is same like yours but it still demanding to download opencvmanager for running the app on android
    – ARG
    Mar 16, 2015 at 22:57
0

LOCAL_SRC_FILES show the file where your native code resides. If you use native OpenCV code then you have to add the name of your cpp file here. If you do not have a native part then you should add the OpenCV library to the libs folder of your project. (in case of static initialization). Please check this page for details.

5
  • Right, I do use some native opencv, and that is the correct name of the file. As I said, if I remove those two lines at the top, it compiles and runs fine(including calling the JNI files)
    – Jameo
    Feb 13, 2013 at 18:15
  • Now I see, so you could run the program with dynamic linking but not with static.. I thought you cannot link and run at all. For static linking you need to set OPENCV_LIB_TYPE := STATIC in Android.mk.
    – rics
    Feb 13, 2013 at 19:09
  • I've played around with adding that, by itself, I still get the same error (that is, adding it between the includes at the top). I've also tried it with the other two, both before and after, so I don't think its an order thing
    – Jameo
    Feb 13, 2013 at 19:19
  • 1
    Have you copied opencv dynamic libraries to the project's libs directory?
    – rics
    Feb 13, 2013 at 20:42
  • I just figured it out, I believe it was just an issue with the the APP_ABI format I had. When I took a closer look at the error I was getting it made me think to check which platforms it was building for. Thanks for your help!
    – Jameo
    Feb 13, 2013 at 20:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.