fluidsynth library file compilation to .so file in android - android

I am trying to compile the files from https://bitbucket.org/kunstmusik/fluidsynth-android to .so file. The files from this site are .c and .h which have the include files. I have installed ndk, configured it.
I have created a new project in eclipse
created the jni folder and copied the files from the web site to this folder
in command prompt in the jni folder, I issued the command ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk. This ran without error
In the /obj/local/ folder, files were created with .o and .d in the fluidsynth-andriod folder. There is also a .a file in armeabi and aremabi-v7a. I assume the .a is a static library. Do I need to create a .so file? Do i need to link the c/c++ to java. If so how do I do this.
Please help...

I was running into this same issue myself. The Android.mk file included in the fluidsynth-android code contains the line
include $(BUILD_STATIC_LIBRARY)
This is what causes the .a files to be generated.
If you change this to
include $(BUILD_SHARED_LIBRARY)
you will get .so files instead of .a files.

Related

What does cpp, jni, jniLibs directories, and android.mk and CMake.txt do in Android

When configuring a project to add C and C++ in an Android project a few things come up in a project's directory tree.
There's the cpp, jniLibs, and the jni directories.
There are also android.mk and CMakeLists.txt files.
What are the purposes \ what should be included in the cpp, jniLibs, and the jni directories?
Do android.mk and CMakeLists.txt work interchangeably?
Thank you all in advance.
cpp is a directory where you put your cpp code.
jniLibs is an optional directory, can be added if you need to include some external libs (.so files).
CMakeLists.txt is a configuration file for CMake, which is a build tool for c++ code.
android.mk is a configuration file used to build cpp code, similar to GNU makefile. No longer used now, replaced by CMake tool. You should use CMake now instead of android.mk, but you can still used if you want.
CMakeLists.txt is a replacement of the old way android.mk

How to include ffmpeg in my jni folder and build .so file?

I have successfully build ffmpeg.
After that I have added the include.h files in my jni folder.
jni folder
My ffmpeg-jni.c file :
ffmpeg-jni.c
When I build ndk . It comes like this.
error in ndk-build
After adding common.h . It comes with another one error.
in command prompt
scroll 1
scroll 2
How can I solve this and build .so file?
These are my ffmpeg build files

"openssl/aes.h: No such file or directory" under Android

I'm trying to compile to android environment. And because of that I get the following error:
error: openssl/aes.h: No such file or directory
I find some solution in stack but, I don't get how to end the process to be able to compile.
I already compiled one version of openssl were should I add the libs? or how can I generate the *.a?
Do you know how can I add this library to the arm-linux-androideabi-g++ that I need to run to be able to pass this problem?
[1] Get openssl library which has aes.h file in its include folder.
[2] If you have compiled openssl library in your lib folder then add to -lssl or -lopenssl to your command line.
Here you can find openssl includes: openssl
Download this includes and put them in some folder in your project, i.e. project_dir/module_dir/jni/openssl-includes.
Then you need set a LOCAL_C_INCLUDES variable in your Android.mk (which also is in jni folder:
LOCAL_C_INCLUDES += ./openssl-includes
After that, you can include files in openssl-includes folder directly by name, i.e.:
#include <aes.h>
If you need an *.a file as output, you should include BUILD_STATIC_LIBRARY in Android.mk, if you need a *.so lib, include BUILD_SHARED_LIBRARY.

How to include a binary file with Android NDK project?

I know its bad practice but whats the best way to include a binary file with Android NDK project? The file should be executable with the system command.
I don't want to copy it manually copy to the device but distribute it within my .apk.
It is enough to rename the executable to "lib_myexecutable_.so" and put it in libs/armeabi folder under your project root: this file will be extracted by the Package Manager on the device to /data/data/your.package.full.name/lib, with executable permissions.
If you use ndk-build to build myexecutable, all ./libs/$(TARGET_ARCH_ABI) directory will be refreshed.
To automate the rename operation, use the following in your Android.mk:
... # whatever you have to define the executable
include $(BUILD_EXECUTABLE)
# immediately after this,
all: .libs/$(TARGET_ARCH_ABI)/lib_myexecutable_.so
.libs/$(TARGET_ARCH_ABI)/lib_myexecutable_.so: $(LOCAL_INSTALLED)
<tab>$(call host-mv, $<, $#)

Android : link prebuilt shared library (.so) within jar file in NDK

I've a static java library compiled as a jar file.
This jar loads a .so library using System.loadLibrary.
Then another Android application project links statically the jar file.
Everything is compiled using an Android.mk file in the NDK...how can I make the shared native library being included and correctly loaded from my final application (and "seen" from the jar code)?
Ok I solved the problem by using these instructions in Android.mk:
$(shell cp $(wildcard $(LOCAL_PATH)/libs/armeabi/*.so) $(TARGET_OUT_INTERMEDIATE_LIBRARIES))
LOCAL_JNI_SHARED_LIBRARIES:= libMyLib
just before
include $(BUILD_PACKAGE)

Categories

Resources