如何编译电报jni文件夹 [英] How to compile telegram jni folder
问题描述
我正在尝试在 github.com/DrKLO/Telegram/使用ndk
I am trying to compile jni folder in telegram source code in github.com/DrKLO/Telegram/ with ndk
但是当我在ndk文件夹的cmd中编写ndk-build时 像:
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
F:\ndk\android-ndk-r10>ndk-build -C F:\Workspace\Android\Telegram-master-1-12-2016\Telegram-master\TMessagesProj\jni
我遇到一些错误,并且没有创建libs文件夹
I get some error and libs folder not created
当我将ndk路径添加到android studio并手动添加jni文件夹时,android studio说找不到一些头文件
When i add ndk path to android studio and add jni folder manually android studio say can not find some header files
遵循此问题下载 Cygwin 并使用它,但再次收到类似ndk-build
Following this question download Cygwin and use it, but again get this error like ndk-build
$ndkbuild
[armeabi] SharedLibrary:libtmessages.15.so
[armeabi] SharedLibrary : libtmessages.15.so
process_begin:CreateProcess(........,
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:/工作区/Android/ Telegram-master-1-12-2016/Telegram-master/TMessagesProj//obj/local/armeabi/libtm essages.15.so,...)失败
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):参数不正确.
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]错误87
make.exe: *** [F:/Workspace/Android/Telegram-master-1-12-2016/Telegram-master/TMessagesProj//obj/local/armeabi/libtmessages.15.so] Error 87
该如何解决?
推荐答案
重要的更新问题: 在3.18版本中,下载电报源项目后,如果转到jni文件夹,则会找到一个空的名为libtgvoip的文件夹,并用所需的文件填充该文件夹: 1-从githum转到电报源,转到jni文件夹,然后单击libtgvoip @ eb813e1文件夹(@表示这是一个参考文件夹). 2-也下载该库! 3-将其内容复制到前面讨论的空文件夹中!
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-将NDK目录添加到环境PATH变量.
1- Add NDK directory to environment PATH variable.
2-打开Android.mk并添加以下行: LOCAL_SHORT_COMMANDS:= true
2- open Android.mk and add the following line: LOCAL_SHORT_COMMANDS := true
3-打开Application.mk并添加以下行: APP_SHORT_COMMANDS:= true
3- open Application.mk and add the following line: APP_SHORT_COMMANDS := true
4-以管理员身份打开命令提示符,并导航到jni文件夹,如下所示: (重要:在最新版本的电报中,您应该导航到jni父文件夹而不是jni文件夹)
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-只需执行ndk-build命令
5- just execute ndk-build command
然后ndk将开始构建.so文件:
Then ndk will start building .so files:
等待直到完成任务,可能会显示一些警告,但并不重要.最终,您将在obj目录中拥有所有共享库(.so文件): (重要:在电报的最新版本中,.so文件将在lib文件夹中创建,并且一切准备就绪)
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)
然后转到每个文件夹,并删除除libtmessages.22.so外的所有内容. 创建一个libs文件夹并将该三个目录复制到其中:
then goto each of these folders and delete everything except libtmessages.22.so. create a libs folder and copy that three directory into it:
建立并享受乐趣! (请记住,使用您的应用ID和app_hash填写org.telegram.messenger.BuildVars类中的变量.在此处了解更多信息)
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)
这篇关于如何编译电报jni文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!