Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 399
maoprogrammer Avatar asked Jan 12 '16 14:01

maoprogrammer


2 Answers

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

enter image description here

3- open Application.mk and add the following line: APP_SHORT_COMMANDS := true

enter image description here

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)

enter image description here

5- just execute ndk-build command

enter image description here

Then ndk will start building .so files:

enter image description here

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)

enter image description here

then goto each of these folders and delete everything except libtmessages.22.so. create a libs folder and copy that three directory into it:

enter image description here

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)

like image 166
farhad.kargaran Avatar answered Sep 30 '22 12:09

farhad.kargaran


Just remove the object file. This error most likely appeared after the previous build was interrupted and object file was not generated completely. enter image description here

like image 22
sirmagid Avatar answered Sep 30 '22 12:09

sirmagid