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

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

Related

PJSIP + FFMPEG build error

I'm trying to build PJSIP with FFMPEG for Android.
For building FFMPEG with rtmp and openssl, I use this project:
https://github.com/cine-io/android-ffmpeg-with-rtmp
and it compiles pretty well.
Then I'm compiling pjsip 2.6 with ffmpeg. Here is the part from my build file:
APP_PLATFORM=android-${TARGET_ANDROID_API} NDK_TOOLCHAIN_VERSION=4.9 TARGET_ABI=$arch ./configure-android --use-ndk-cflags \
--with-ssl="${OPENSSL_BUILD_OUT_PATH}/libs/${arch}" \
--with-ffmpeg="${BASE_DIR}/ffmpeg-output"
>>"${FINAL_BUILD_LOGS}/${arch}.log" 2>&1
My target ABI is armeabi.
Also, i've defined these two flags:
#define PJMEDIA_HAS_VIDEO 1
#define PJMEDIA_HAS_FFMPEG 1
But the build failed with a bunch of these two errors:
error: cannot find -lbz2
error: cannot find -lasound
A have libasound2-dev and bzip2 installed on my Ubuntu 16.04 LTS VM.
Before that, I've successfully made pjsip builds with OpenH264 with no errors like this.
Is there any way to tell linker(or whatever it is) how to find those packages?
Solve that problem (thx #NandhaKumar) by compiling .a libs for each library above and adding them to pjsip library path:
Build .a libs.
Copy libs to {PJPROJECT}/third_party/lib/ folder.
Go to the build.mak.in file in your PJSIP project folder.
Add the following lines:
APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libbz2.a
APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libasound.a
In my case (and I still don't know why) second line and defining another line
(APP_THIRD_PARTY_LIBS += -lsound or APP_THIRD_PARTY_LIBS += -lasound) doesn't help, so I just copied this library into the android_ndk folder:
android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9/libasound.a

DLib c++ linking error on android studio gradle file

I want to use dlib library in my android project which is written in c++.
I selected c++ language because it will support iOS also.
So I follow these steps:
I created android ndk project and I included that dlib library
directly in my c++ code folder.
I import .h files and I generated a app gradle file in android studio
project.
But when I am getting library .h files errors, means internal .h files getting errors.
Error:error: linker command failed with exit code 1 (use -v to see invocation)
Error:Build command failed.
Error:org.gradle.internal.UncheckedException:

How to compile telegram jni folder

I am trying to compile jni folder in telegram source code in github.com/DrKLO/Telegram/ with ndk
But when i am write ndk-build in cmd in ndk folder
like:
F:\ndk\android-ndk-r10>ndk-build -C F:\Workspace\Android\Telegram-master-1-12-2016\Telegram-master\TMessagesProj\jni
I get some error and libs folder not created
When i add ndk path to android studio and add jni folder manually android studio say can not find some header files
Following this question download Cygwin and use it, but again get this error like ndk-build
$ndkbuild
[armeabi] SharedLibrary : libtmessages.15.so
process_begin: CreateProcess(........,
F:/ndk/android-ndk-r10/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi
/thumb/libgnustl_static.a -lgcc -no-canonical-prefixes
-Wl,--no-undefined -Wl,-z ,noexecstack -Wl,-z,relro -Wl,-z,now
-LF:/ndk/android-ndk-r10/platforms/android-
9/arch-arm/usr/lib -ljnigraphics -llog -lz -ldl -lc -lm -o
F:/Workspace/Android/
Telegram-master-1-12-2016/Telegram-master/TMessagesProj//obj/local/armeabi/libtm
essages.15.so, ...) failed
make (e=87): The parameter is incorrect.
make.exe: *** [F:/Workspace/Android/Telegram-master-1-12-2016/Telegram-master/TMessagesProj//obj/local/armeabi/libtmessages.15.so] Error 87
How fix this?
Important update issue:
in 3.18 version, after downloading telegram source project, if you go to jni folder you will find and empty folder named libtgvoip, to fill it with needed files:
1- go to telegram source from githum, goto jni folder and click on libtgvoip # eb813e1 folder (# means that this is a refrence folder).
2- download that library too!
3- copy its content in empty folder discussed earlier!
Now lets begin:
Its very easy.
1- Add NDK directory to environment PATH variable.
2- open Android.mk and add the following line:
LOCAL_SHORT_COMMANDS := true
3- open Application.mk and add the following line:
APP_SHORT_COMMANDS := true
4- open command prompt as administrator and navigate to jni folder like this:
(important: in last version of telegram you should navigate to jni parent folder instead of jni folder)
5- just execute ndk-build command
Then ndk will start building .so files:
wait until it finish the task, maybe some warnings displayed but not important. finally you will have all shared library (.so files) in the obj directory:
(important: in last version of telegram .so files will create in lib folder and everything is ready to build)
then goto each of these folders and delete everything except libtmessages.22.so.
create a libs folder and copy that three directory into it:
Build and have fun! (remember to fill out variables in org.telegram.messenger.BuildVars class with your app id and app_hash. read more here)
Just remove the object file.
This error most likely appeared after the previous build was interrupted and object file was not generated completely.
Download the android-ndk Then go to the Project directory (./TMessagesProj) and execute ndk-build.
Then re-run the gradle build which packages the native libs into the apk.

How to change .so files directory generated by ndk-build command?

I use android studio with ndk and opencv. By default ndk-build command builds files under src/main/libs folder . I want to change it to src/main/jniLibs.
Add the option NDK_LIBS_OUT=<library output path> for ndk-build.

fluidsynth library file compilation to .so file in 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.

Categories

Resources