Android OpenCV - "error: cannot find -lopencv_java" - android

I'm trying to develope a native code with OpenCV using IntelliJ IDEA 13.1.4. When I try to ndk-build the code provided in mixedprocessing sample, I have this error:
[armeabi-v7a] Compile++ thumb: com_sample_jniLib <= com_sample_jniLib.cpp
[armeabi-v7a] SharedLibrary : libcom_sample_jniLib.so
D:/Workspace/android-ndk-r10/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lopencv_java
make.exe: *** [obj/local/armeabi-v7a/libcom_voxar_tracker_TrackerLib.so] Error 1
D:\Workspace\android-ndk-r10\sources\cxx-stl\stlport\stlport
Basically, he can't find -lopencv_java.
Here is my Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include jni/opencv/OpenCV.mk
LOCAL_SRC_FILES := com_voxar_tracker_TrackerLib.cpp
LOCAL_MODULE := com_voxar_tracker_TrackerLib
LOCAL_LDLIBS += -llog -ldl
include $(BUILD_SHARED_LIBRARY)
And my Application.mk:
APP_STL := stlport_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := all
As I told before, I'm using IntelliJ IDEA 13.1.4, OpenCV 2.4.9 and Android NDK r10 32-bit on Windows 8.1. Does anybody have any idea of what that could be?

You seem to have forgot OPENCV_INSTALL_MODULES:=on in your Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
OPENCV_INSTALL_MODULES:=on
include jni/opencv/OpenCV.mk
LOCAL_SRC_FILES := com_voxar_tracker_TrackerLib.cpp
LOCAL_MODULE := com_voxar_tracker_TrackerLib
LOCAL_LDLIBS += -llog -ldl
include $(BUILD_SHARED_LIBRARY)

Related

NDK cannot locate symbol "_Znwj"

I've compiled a 3rd party library on Linux using a standalone toolchain, and I'm now trying to load that library in my app.
Problem is I'm getting java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_Znwj" referenced by "libmxnet_predict.so"
I've tried adding CFLAGS and LDFLAGS, both APP & LOCAL, but to no avail.
Before you ask, I'm developing with ADT because I have to.
This is my Application.mk:
APP_STL := gnustl_shared
APP_CFLAGS += -std=c++11
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_PLATFORM := android-19
My (simplified) Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
OPENCV_LIB_TYPE:=SHARED
OPENCV_CAMERA_MODULES:=off
OPENCV_INSTALL_MODULES:=on
NDK_TOOLCHAIN_VERSION=4.9
include $(CLEAR_VARS)
include $(PREBUILT_SHARED_LIBRARIES)
include C:/OpenCV-2.4.8-android-sdk/sdk/native/jni/OpenCV.mk
LOCAL_MODULE := FreshubML
LOCAL_C_INCLUDES += $(LOCAL_PATH)
LOCAL_SRC_FILES := Mldevlib.cpp \
Tablet.cpp \
Interface.cpp \
LOCAL_LDLIBS += -llog -ldl -landroid -lm -ljnigraphics -lstdc++
C:\KitchenVision\Workspaces\MLDevWorkspace\MLDev\assets\share
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libmxnet_predict
LOCAL_SRC_FILES := lib/armeabi-v7a/libmxnet_predict.so
include $(PREBUILT_SHARED_LIBRARY)
Searching the standalone toolchain I saw that the symbol was referenced in libgnust_shared.so which I added to my project via APP_STL and in libstdc++.so but still, same error.
How do I get this to work?

Android NDK/JNI UnsatisfiedLinkError With .So library

I'm new to Android NDK, and I'm currently trying to build a RTMP C client for Android (and later iOS). Currently, I'm running into an issue where the application crashes as soon as I try to load my library:
static {
System.loadLibrary("test");
}
The exception I get is
java.lang.UnsatisfiedLinkError: dlopen failed: could not load library "librtmp.so.1" needed by "libtest.so"; caused by library "librtmp.so.1" not found
I'm honestly completely lost. ndk-build doesn't return any errors:
[armeabi] Prebuilt : rtmp.so <= jni/rtmp/
[armeabi] Install : rtmp.so => libs/armeabi/rtmp.so
[armeabi] Compile thumb : test <= RTMPClient.c
[armeabi] SharedLibrary : libtest.so
[armeabi] Install : libtest.so => libs/armeabi/libtest.so
I've tried loading in the rtmp librarary via System.loadLibrary("rtmp"), but no dice.
Android.mk
LOCAL_PATH:= $(call my-dir)
LIBS_PATH := libs/$(TARGET_ARCH_ABI)
include $(CLEAR_VARS)
LOCAL_MODULE := rtmp
LOCAL_SRC_FILES := rtmp/rtmp.so
LOCAL_C_INCLUDES := rtmp/
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := test
LOCAL_SRC_FILES := RTMPClient.c
LOCAL_LDLIBS := -llog
LOCAL_SHARED_LIBRARIES += rtmp
include $(BUILD_SHARED_LIBRARY)
Application.mk
APP_PLATFORM:=android-19
My RTMPClient.c uses some structs and functions from rtmp like so:
#include <rtmp/rtmp.h>
I'm not sure where librtmp.so.1 is coming from, but I also found it in my libtest.so with arm-linux-andrioideabi-readelf:
0x00000001 (NEEDED) Shared library: [librtmp.so.1]
Any ideas on how I can fix this?
EDIT: I got the rtmp.so file from here. I was sent there from the KODI librtmp update page
I ended up throwing out my rtmp.so file, and instead grabbed the jni files from rtmpdump-android. After putting those file in, changing my android.mk file to:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES += \
librtmp/amf.c \
librtmp/hashswf.c \
librtmp/log.c \
librtmp/parseurl.c \
librtmp/rtmp.c
LOCAL_CFLAGS := -D__STDC_CONSTANT_MACROS -DNO_CRYPTO
LOCAL_LDLIBS := -llog
LOCAL_MODULE := librtmp
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := dump
LOCAL_CFLAGS := -DRTMPDUMP_VERSION=\"v2.4\"
LOCAL_LDLIBS := -llog
LOCAL_SRC_FILES := dump/rtmpdump.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../librtmp
LOCAL_C_INCLUDES += dump/rtmpdump.h
LOCAL_STATIC_LIBRARIES := librtmp
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := test
LOCAL_SRC_FILES := nelly.c nelly_tables.c RTMPClient.c
LOCAL_LDLIBS := -llog
LOCAL_SHARED_LIBRARIES += dump
include $(BUILD_SHARED_LIBRARY)
And changing my RTMPClient.c file to include #include "librtmp/rtmp.h" instead of #include <rtmp/rtmp.h>, the file compiled and ran on my device without any issues.

Android | fatal error: GLES/gl.h: No such file or directory

Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := test
LOCAL_CFLAGS := -Wall
LOCAL_SRC_FILES := test.c
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM
include $(BUILD_SHARED_LIBRARY)
I run....
ndk-build NDK_PROJECT_PATH=./ APP_BUILD_SCRIPT=./Android.mk
and I get....
Compile thumb : test <= test.c
./test.c:8:29: fatal error: GLES/gl.h: No such file or directory
compilation terminated.
make: * [obj/local/armeabi/objs/test/test.o] Error 1
Now I am guessing adding a cflag of -I/include or a C_Include in the Android.mk will work but shouldn't that be handled by the -lGLESv1_CM.
Making an Application.mk file worked for me....
APP_ABI := armeabi armeabi-v7a
APP_PLATFORM := android-8

android ndk error "no such file or directory"?

I have some header files in include folder.
Here is the Android.mk file contents.
include $(call all-subdir-makefiles)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := fpdfembedsdk
LOCAL_SRC_FILES := FoxitEMBSDK_EMBJavaSupport.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_LDLIBS := -llog -g -L. -ljnigraphics
LOCAL_LDLIBS += libfpdfemb_android.a
include $(BUILD_SHARED_LIBRARY)
I am getting the following error.
$ /cygdrive/c/Android/android-ndk/ndk-build
Compile++ thumb : fpdfembedsdk <= FoxitEMBSDK_EMBJavaSupport.cpp
jni/FoxitEMBSDK_EMBJavaSupport.cpp:9:21: fatal error: fs_base.h: No such file or directory
compilation terminated.
/cygdrive/c/Android/android-ndk/build/core/build-binary.mk:255: recipe for target `obj/local/armeabi/objs/fpdfembedsdk/FoxitEMBSDK_EMBJavaSupport.o' failed
make: *** [obj/local/armeabi/objs/fpdfembedsdk/FoxitEMBSDK_EMBJavaSupport.o] Error 1
can anybody pls help me?
LOCAL_C_INCLUDES := $(LOCAL_PATH)
Check that. I guess you pass the wrong path. Are you sure all headers are there?

NDK build error

I am trying to use a pre built library within my project...its name is libfreeimage.so...
I am not able to build it properly using the NDK-build....
The error log has been pasted here...
please help me in this regard...
flock#QS57:~/Desktop/android-imagefilter-ndk$ /home/flock/ANDROID/android-ndk-r8/ndk-build
Prebuilt : libfreeimage.so <= jni/
Install : libfreeimage.so => libs/armeabi/libfreeimage.so
/home/flock/ANDROID/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-strip: Unable to recognise the format of the input file `./libs/armeabi/libfreeimage.so'
make: *** [libs/armeabi/libfreeimage.so] Error 1
make: *** Deleting file libs/armeabi/libfreeimage.so
flock#QS57:~/Desktop/android-imagefilter-ndk$
My android.mk file-
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libfreeimage
LOCAL_SRC_FILES := libfreeimage.a
include $(PREBUILT_SHARED_LIBRARY)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := imageprocessing
LOCAL_SRC_FILES := imageprocessing.c
LOCAL_SHARED_LIBRARIES := libfreeimage
LOCAL_LDLIBS := -lm -llog -ljnigraphics
include $(BUILD_SHARED_LIBRARY)
You need to use
include ($BUILD_STATIC_LIBRARY)
instead of
include ($BUILD_SHARED_LIBRARY)
This will give you the desired .a file, not the .so.

Categories

Resources