NDK build error - android

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.

Related

Android : Loading pre-built library - Circular dependency dropped

I am trying to import a module into my project.
Android.mk in module:
LOCAL_PATH := $(call my-dir)
include $(CEAR_VARS)
LOCAL_MODULE := fromhere1
LOCAL_MODULE_FILENAME := fromhere1
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libfromhere.so
include $(PREBUILT_SHARED_LIBRARY)
libfromhere.so is built by ndk-build
Android.mk in my project:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := native
LOCAL_MODULE_FILENAME := libnative
LOCAL_SRC_FILES := native.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/
LOCAL_SHARED_LIBRARIES := fromhere1
include $(BUILD_SHARED_LIBRARY)
$(call import-module,module)
When I run ndk-build, I get error
[arm64-v8a] Compile : native <= native.c
make: Circular /home/raghuram/DS-5-Workspace/helloworld/obj/local/arm64-v8a/libnative.so <- /home/raghuram/DS-5-Workspace/helloworld/obj/local/arm64-v8a/libnative.so dependency dropped.
[arm64-v8a] SharedLibrary : libnative.so
aarch64-linux-android-g++: error: /home/raghuram/DS-5-Workspace/helloworld/obj/local/arm64-v8a/libnative.so: No such file or directory
make: *** [/home/raghuram/DS-5-Workspace/helloworld/obj/local/arm64-v8a/libnative.so] Error 1.
I don't understand why that circular dependency is arising.
I followed proper syntax.
After include $(PREBUILT_SHARED_LIBRARY) you have to clear the variable may be you are again prebuilding another library... this stuff solved my issue :)
LOCAL_PATH := $(call my-dir)
include $(CEAR_VARS)
LOCAL_MODULE := fromhere1
LOCAL_MODULE_FILENAME := fromhere1
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libfromhere.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CEAR_VARS)
LOCAL_MODULE := fromhere2
LOCAL_MODULE_FILENAME := fromhere2
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libfromhere2.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CEAR_VARS)
My mistake is the value of LOCAL_MODULE_FILENAME. It must be libfromhere1 instead of fromhere1.
ndk just puts .so suffix to the given name but it won't put lib prefix.
Always it is better to give name by yourself than letting ndk name it for you.
But I didn't understand why circular dependency arose because of that.

Android.mk No rule to make target '*.c', needed by '*.o'. Stop

I have some problem.
I use ndk-build but I can't make library *.so.
--------------------------------- Error ---------------------------------
nathaniel#Nathaniel-MSI /work/workspace/HealthCare $ ndk-build
make: *** No rule to make target `jni/jni/src/filterData.c', needed by
`obj/local/armeabi/objs/HealthCare/jni/src/filterData.o'. Stop.
Under the my Android.mk source, help me please
--------------------------------- Android.mk ---------------------------------
LOCAL_PATH := $(call my-dir)
SRCS := $(wildcard $(LOCAL_PATH)/src/*.c)
include $(CLEAR_VARS)
LOCAL_MODULE := HealthCare
LOCAL_SRC_FILES := $(SRCS)
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
LOCAL_SRC_FILES := $(SRCS:$(LOCAL_PATH)/%=%)
EDITED
LOCAL_C_INCLUDES := $(LOCAL_PATH)/src

Android NDK : Aborting. Stop

I'm trying to call C++ method in Java coding.
I received the Android NDK : Aborting. Stop when defined the Android.mk file as below :
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpeg
LOCAL_SRC_FILES := libs/ffmpeg.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpeg
LOCAL_SRC_FILES := ffmpeg.cpp
LOCAL_SHARED_LIBRARIES := ffmpeg
include $(BUILD_SHARED_LIBRARY)
But if I defined like this, it run successfully :
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpeg
LOCAL_SRC_FILES := libs/ffmpeg.so
include $(BUILD_SHARED_LIBRARY)
Questions :
1 - How to fix this error?
2 - In Android.mk file, Can not call libs/ffmpeg.so and ffmpeg.cpp in the same time?
People who know this,
Please tell me,
Thanks,
p/s : Project structure :
When seeing the Android.mk structure.
I think I need change Android.mk file like this :
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpeg
LOCAL_SRC_FILES := libs/ffmpeg.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := final_ffmpeg
LOCAL_SRC_FILES := ffmpeg.cpp
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
LOCAL_PREBUILTS := libs/ffmpeg.so
#libavformat libavcodec libswscale libavutil
include $(BUILD_SHARED_LIBRARY)
The result will help me :
It still be exactly when you need call the C++ function in C++ file from Java file.

No rule to make target error android ndk build sqlite

I am trying to build sqlite using the android NDK to use a sqlite3_create_function but am getting No rule to make target error. make: *** No rule to make target '/fts3-rank.c', needed by '.../obj/local/armeabi/objs/fts3-rank//fts3-rank.o'. Stop. This Android.mk file is based off of the one on this website: http://www.roman10.net/how-to-compile-sqlite-for-android-using-ndk/
#LOCAL_PATH is used to locate source files in the development tree.
#the macro my-dir provided by the build system, indicates the path of the current directory
LOCAL_PATH := $(call my_dir)
#####################################################################
# build sqlite3 #
#####################################################################
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/sqlite-amalgamation-3071700
LOCAL_MODULE := sqlite3
LOCAL_SRC_FILES := $(LOCAL_PATH)/sqlite-amalgamation-3071700/sqlite3.c
include $(BUILD_STATIC_LIBRARY)
#include $(BUILD_SHARED_LIBRARY)
#####################################################################
# build our code #
#####################################################################
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/sqlite-amalgamation-3071700
LOCAL_MODULE := fts3-rank
LOCAL_SRC_FILES := fts3-rank.c
LOCAL_STATIC_LIBRARIES := libsqlite3
#LOCAL_SHARED_LIBRARIES:=libsqlite3
LOCAL_LDLIBS := -llog -lm
#include $(BUILD_SHARED_LIBRARY)
include $(BUILD_EXECUTABLE)
May be There some different reason of this error.
It may be LOCAL_PATH value incorrect so check LOCAL_PATH initialization. Remove any extra spaces in that.
LOCAL_PATH := $(call my-dir)__
Your jni library should be loaded in memory before calling any jni function. Load jni library as follow.
static {
System.loadLibrary("libmy-jni-module");
}
You may refer this discussion on so
I fixed it somehow by trial and error. It was very strange. I guess it's because I was using LOCAL_PATH twice?
I finally got it to build using this Android.mk
#LOCAL_PATH is used to locate source files in the development tree.
#the macro my-dir provided by the build system, indicates the path of the current directory
LOCAL_PATH := $(call my-dir)
#####################################################################
# build sqlite3 #
#####################################################################
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := sqlite-amalgamation-3071700
LOCAL_MODULE := sqlite3
LOCAL_SRC_FILES := sqlite-amalgamation-3071700/sqlite3.c
include $(BUILD_STATIC_LIBRARY)
#include $(BUILD_SHARED_LIBRARY)
#####################################################################
# build our code #
#####################################################################
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/sqlite-amalgamation-3071700
LOCAL_MODULE := fts3-rank
LOCAL_SRC_FILES := fts3-rank.c
LOCAL_STATIC_LIBRARIES := libsqlite3
#LOCAL_SHARED_LIBRARIES:=libsqlite3
LOCAL_LDLIBS := -llog -lm
include $(BUILD_SHARED_LIBRARY)
#need main function to have executable
#include $(BUILD_EXECUTABLE)

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?

Categories

Resources