Jameo
Jameo

Reputation: 4607

Static Linking OpenCV 2.4.3.2

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

Upvotes: 0

Views: 2495

Answers (2)

Jameo
Jameo

Reputation: 4607

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

Upvotes: 1

rics
rics

Reputation: 5596

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.

Upvotes: 0

Related Questions