guys,
My XXX.mk for building the Android executable XXX describes like this:
...
LOCAL_STATIC_LIBRARIES := \
libYYY
LOCAL_MODULE := XXX
LOCAL_PROPRIETARY_MODULE := $(ENABLE_VENDOR_MODULE)
LOCAL_32_BIT_ONLY := true
include $(BUILD_EXECUTABLE)
It is the same directory with the prebuilt libYYY.a and an Android.mk like this:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/XXX.mk
When executing mm command,
I got the following error:
FAILED: XXX.mk: error: "XXX(EXECUTABLES android-arm) missing libYYY
(STATIC_LIBRARIES android-arm)"
The error is still there even I tried to change LOCAL_STATIC_LIBRARIES to libYYY.a or YYY.
Any suggestion?
Related
I'm using Eclipse for Windows, Android SDK and Android NDK (I'm sure that all paths are set correclty).
I'm looking for compiling a .c library locatad in jni folder, but some error occur. This library depends on external .so libraries, these are my Makefile, Android.mk and library:
jni folder.
Android.mk :
LOCAL_PATH := $(call my-dir)
#---------------------------------------------------------------
include $(CLEAR_VARS)
LOCAL_MODULE := pdbeatdetection
LOCAL_C_INCLUDES := $(LOCAL_PATH)\C:\PROGRAMMING\pd-0.45-4\src
LOCAL_CFLAGS := -DPD
LOCAL_SRC_FILES := pdbeatdetection.c
LOCAL_LDLIBS := -L$(LOCAL_PATH)\C:\PROGRAMMING\PdCore\libs\armeabi\ -lpdnative
include $(BUILD_SHARED_LIBRARY)
Makefile :
all:
C:\PROGRAMMING\android-ndk-r10d\ndk-build.cmd
mkdir ../tmp
cp ..\libs\armeabi\libpdBeatDetection.so ..\tmp\pdbeatdetection.pd_linux
cd ..\tmp && zip externals.zip *.pd_linux && mv externals.zip ..\res\raw
rm -rf ..\tmp
I followed some tutorials, but I'm not still able to solve this issue.
Could you please give me suggestions to compile the library, avoiding the following error?
ERROR:
Description Resource Path Location Type
make.exe: *** [obj/local/armeabi/libpdbeatdetection.so] Error 1 Discoteque C/C++ Problem
Thank you!
If your code depends on an external .so file, you should declare it properly using the PREBUILT_SHARED_LIBRARY macro, like so:
LOCAL_PATH := $(call my-dir)
#dependency
include $(CLEAR_VARS)
LOCAL_MODULE := pdnative
LOCAL_SRC_FILES := C:/PROGRAMMING/PdCore/libs/$(TARGET_ARCH_ABI)/libpdnative.so
LOCAL_EXPORT_C_INCLUDES := C:/PROGRAMMING/pd-0.45-4/src
include $(PREBUILT_SHARED_LIBRARY)
#your module
include $(CLEAR_VARS)
LOCAL_MODULE := pdbeatdetection
LOCAL_SRC_FILES := pdbeatdetection.c
LOCAL_CFLAGS := -DPD
include $(BUILD_SHARED_LIBRARY)
If that's not enough to solve your issue, give us the error reported by calling ndk-build.cmd directly.
I am testing facedetection program at Android with NDK. I followed all discussions here. I copied all OpenCV's library files inside armeabi and armeabi-v7a into my project libs folder. Then my Android.mk is updated as
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
OPENCV_INSTALL_MODULES := on
OPENCV_CAMERA_MODULES := off
OPENCV_LIB_TYPE := STATIC
include C:\adt-bundle-windows-x86\OpenCV-2.4.9-android-sdk\sdk\native\jni\OpenCV.mk
LOCAL_SRC_FILES := DetectionBasedTracker_jni.cpp
LOCAL_C_INCLUDES += $(LOCAL_PATH)
LOCAL_LDLIBS += -llog -ldl
LOCAL_MODULE := detection_based_tracker
include $(BUILD_SHARED_LIBRARY)
Then I go to command window and type
C:\facedetection\jni\include>javah -classpath ../../bin/classes;C:
\adt-bundle-windows-x86\sdk\platforms\android-18\android.jar -o DetectionBas
edTracker_jni.h org.opencv.samples.facedetect.FdActivity
Error: Class org.opencv.android.CameraBridgeViewBase could not be found.
Then the error is Class org.opencv.android.CameraBridgeViewBase could not be found.
What could be the reason for that error?
Thanks
You are providing wrong \ slash. You need to use this / slash instead.
Please change your below line
include C:\adt-bundle-windows-x86\OpenCV-2.4.9-android-sdk\sdk\native\jni\OpenCV.mk
to
include C:/adt-bundle-windows-x86/OpenCV-2.4.9-android-sdk/sdk/native/jni/OpenCV.mk
I want my native executable to be auto-populated to /data/data/.../lib/. For this it is to be named like lib*.so. But if I try to set this name, Android NDK complains:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libhello.so
LOCAL_SRC_FILES := hello.c
include $(BUILD_EXECUTABLE)
Android NDK: jni/Android.mk:hello.so: LOCAL_MODULE_FILENAME must not contain a file extension
A workaround: install with a name Android NDK wants, then rename after installation:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hello
LOCAL_SRC_FILES := hello.c
include $(BUILD_EXECUTABLE)
all:
mv ${NDK_APP_DST_DIR}/hello ${NDK_APP_DST_DIR}/libhello.so
And your application can call the executable /data/data/<package>/lib/libhello.so without any preparatory steps.
You are trying to build an executable instead of a shared library. You want to change this:
include $(BUILD_EXECUTABLE)
to this:
include $(BUILD_SHARED_LIBRARY)
I have two projects. The output of first one is libtest.so file. Using this shared object file in the 2nd project, i want to generate final android executable, AndroidExe.
I generated libtest.so and its Android.mk is given below
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS := -g
LOCAL_ARM_MODE := arm
LOCAL_MODULE :=test
LOCAL_SRC_FILES := test.c
export LD_LIBRARY_PATH=/data/local/tmp
include $(BUILD_SHARED_LIBRARY)
Here the problem i am facing is that, i don't know how to link this .so file in my final executable project. In this final project, i am using one of the function (sum(a,b)) defined in the .so lib.While do build, showing error undefined reference to 'sum'.Its Android.mk file is given below:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS := -g
LOCAL_ARM_MODE := arm
LOCAL_MODULE :=AndroidExe
LOCAL_SHARED_LIBRARIES := libtest.so
LOCAL_SRC_FILES := AndroidExe.c
include $(BUILD_EXECUTABLE)
just check ndk documentation and try some of the samples.
I tried to compile a shared library and an executable which use these library.
All sources and headers are in the same directory.
I use these Android.mk
==================libsample.so
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libsample
LOCAL_MODULE_TAGS = optional
LOCAL_PRELINK_MODULE := false
LOCAL_SRC_FILES := libsample.c
include $(BUILD_SHARED_LIBRARY)
=======================tstsample
include $(CLEAR_VARS)
LOCAL_MODULE := tstsample
LOCAL_SHARED_LIBRARY := libsample
LOCAL_CFLAGS :=-w
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := cmd.c main.c test.c
include $(BUILD_EXECUTABLE)
===================================
I obtained these error :
error: undefined reference to "each function of my library"
My library is compiled and put in the directory :
:
out/target/product/boadname/system/lib/
I also copied this library in the current directory. but I obtained the same error.
Do you have any suggestions?
Thanks by advance
If this was not a typo while copying your Android.mk to SO, then the following sed command should resolve your problem:
s/LOCAL_SHARED_LIBRARY/LOCAL_SHARED_LIBRARIES/