grishka / libtgvoip

VoIP library for Telegram clients
The Unlicense
387 stars 156 forks source link

Build Error on Windows and Linux #8

Closed javadch closed 7 years ago

javadch commented 7 years ago

I forked the Telegram Android app as well as the libtgvoip repositories to a Windows 7 and a Linux Ubuntu 14.04 machine (64 bits). (I also tried cloning and downloading). The android NDK-BUILD tool does not build the libtgvoip complaining about missing functions references. See bellow. I checked and the files in the "include" folder are there and there is a header file containing the complained functions in the /libtgvoip/external/include/webrtc/gain_control.h. I have read this article and applied the suggested changes into the root mk files under /TMessagesProj/jni but I could not figure out where is the problem.

[armeabi] SharedLibrary : libtmessages.26.so jni/./libtgvoip/EchoCanceller.cpp:82: error: undefined reference to 'WebRtcAgc_Free' jni/./libtgvoip/EchoCanceller.cpp:54: error: undefined reference to 'WebRtcAgc_Create' jni/./libtgvoip/EchoCanceller.cpp:59: error: undefined reference to 'WebRtcAgc_Init' jni/./libtgvoip/EchoCanceller.cpp:60: error: undefined reference to 'WebRtcAgc_set_config' jni/./libtgvoip/EchoCanceller.cpp:167: error: undefined reference to 'WebRtcAgc_AddMic' jni/./libtgvoip/EchoCanceller.cpp:168: error: undefined reference to 'WebRtcAgc_Process' jni/./libtgvoip/EchoCanceller.cpp:173: error: undefined reference to 'WebRtcAgc_AddMic' jni/./libtgvoip/EchoCanceller.cpp:174: error: undefined reference to 'WebRtcAgc_Process' collect2: error: ld returned 1 exit status make: *** [obj/local/armeabi/libtmessages.26.so] Error 1

grishka commented 7 years ago

You're supposed to clone the Telegram Android app repository recursively. This way you'll always get the compatible version of the libtgvoip submodule checked out automatically.

javadch commented 7 years ago

After recursive clone:

[armeabi] Compile arm : tmessages.26 <= opus.c /home/javadch/git/Telegram/TMessagesProj/jni/./opus/src/opus.c:32:18: fatal error: opus.h: No such file or directory

include "opus.h"

              ^

compilation terminated.

The opus.h does not exist in the same directory as opus.c

grishka commented 7 years ago

This error is about the Opus codec, not libtgvoip. Are you sure you didn't mess with the makefile? Also, the Android project is configured to build the native library automatically. So just either import it into Android Studio and build or run ./gradlew build from a terminal, nothing additional to be done for the NDK part.

javadch commented 7 years ago

Thanks, then I will report issues on the Telegram repo.

dsmanhaes commented 7 years ago

have you solved this problem, @javadch ? how?

stek29 commented 7 years ago

@dsmanhaes git submodule init && git submodule update

papmodern commented 7 years ago

I cloned repository recursively, but have the exact same error. When trying to compile with android studio:


make (e=87): The parameter is incorrect.
  make: *** [C:/Users/myuser/Documents/Telegram/TMessagesProj/build/intermediates/ndkBuild/armv7/debug/obj/local/armeabi-v7a/libtmessages.26.so] Error 87

And by using ndk-build command:

[armeabi] SharedLibrary  : libtmessages.26.so
jni/./libtgvoip/EchoCanceller.cpp:82: error: undefined reference to 'WebRtcAgc_Free'
jni/./libtgvoip/EchoCanceller.cpp:54: error: undefined reference to 'WebRtcAgc_Create'
jni/./libtgvoip/EchoCanceller.cpp:59: error: undefined reference to 'WebRtcAgc_Init'
jni/./libtgvoip/EchoCanceller.cpp:60: error: undefined reference to 'WebRtcAgc_set_config'
jni/./libtgvoip/EchoCanceller.cpp:167: error: undefined reference to 'WebRtcAgc_AddMic'
jni/./libtgvoip/EchoCanceller.cpp:168: error: undefined reference to 'WebRtcAgc_Process'
jni/./libtgvoip/EchoCanceller.cpp:173: error: undefined reference to 'WebRtcAgc_AddMic'
jni/./libtgvoip/EchoCanceller.cpp:174: error: undefined reference to 'WebRtcAgc_Process'
collect2.exe: error: ld returned 1 exit status
make: *** [obj/local/armeabi/libtmessages.26.so] Error 1
javadch commented 7 years ago

@dsmanhaes, As far as I remember I did the following steps

1: Installed NDK 2: Did a recursive clone 3: Created Telegram API keys 4: Created GSM keys (I guess it works with Firebase too) 5: Created key stores in Android for Beta and Release 6: Updated gradle.properties 7: Did ./gradlew build on the root project 8: Disabled Lint 9: Added Hokey key

I may have forgotten some steps. Also I repeated each step several times, so this procedure should not be straight-forward.

Hope it helps

dsmanhaes commented 7 years ago

Thanks for all helps.

@stek29, it haven't worked for me

@javadch I'm trying in your way, but I have some doubts What are this GSM Keys, you've mentioned? What udates are needed in gradle.properties? What is Lint? What is Hokey?

I admit I'm very lost with this compilation haha I'm grateful for your help

javadch commented 7 years ago

Gsm us used for push notification via Google services

Hokey is a monitoring and crash report from Microsoft that Telegram is using.

On Jul 8, 2017 5:52 PM, "Diogo Manhães" notifications@github.com wrote:

Thanks for all helps.

@stek29 https://github.com/stek29, it haven't worked for me

@javadch https://github.com/javadch I'm trying in your way, but I have some doubts What are this GSM Keys, you've mentioned? What udates are needed in gradle.properties? What is Lint? What is Hokey?

I admit I'm very lost with this compilation haha I'm grateful for your help

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/grishka/libtgvoip/issues/8#issuecomment-313864231, or mute the thread https://github.com/notifications/unsubscribe-auth/ABeCLNMfNs8ZNpqHFP_au2krlyL_JRwWks5sL6XGgaJpZM4NDee7 .

javadch commented 7 years ago

Lint us a cose analysis and quality check in Android Studio

On Jul 8, 2017 5:52 PM, "Diogo Manhães" notifications@github.com wrote:

Thanks for all helps.

@stek29 https://github.com/stek29, it haven't worked for me

@javadch https://github.com/javadch I'm trying in your way, but I have some doubts What are this GSM Keys, you've mentioned? What udates are needed in gradle.properties? What is Lint? What is Hokey?

I admit I'm very lost with this compilation haha I'm grateful for your help

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/grishka/libtgvoip/issues/8#issuecomment-313864231, or mute the thread https://github.com/notifications/unsubscribe-auth/ABeCLNMfNs8ZNpqHFP_au2krlyL_JRwWks5sL6XGgaJpZM4NDee7 .

stek29 commented 7 years ago

@javadch @dsmanhaes I think he've meant GCM -- Google Cloud Messaging

grishka commented 7 years ago

@stek29 what if he's actually building his own GSM network

stek29 commented 7 years ago

@grishka *ROFL*

stek29 commented 7 years ago

Anyway, Android client definitely needs instructions. What if some guy who is unable to build it can actually do something very cool once he manages to build it? :)

I think Telegram-FOSS-Team/Telegram-FOSS may be useful.

Posting as second comment since some people in this thread seem to use GitHub's email notifications

dsmanhaes commented 7 years ago

@javadch Thanks for the explanations

Actualy I'm in the same trouble of the top of this topic

"jni/./libtgvoip/EchoCanceller.cpp:82: error: undefined reference to 'WebRtcAgc_free" (...)

Do you remember, how you've solved this error?

stek29 commented 7 years ago

@dsmanhaes What if you define TGVOIP_NO_DSP? WebRtcAgc_free seems to be defined in webrtc/modules/audio_processing/agc/legacy/gain_control.h, and it's included only if TGVOIP_NO_DSP is undefined. At least that's what looking into sources for 7 minutes suggests.

javadch commented 7 years ago

1: As first step issue the following recursive clone command to get not only the Telegram source code but also the submodules (TMessagesProj/jni/libtgvoip and TMessagesProj/jni/libtgvoip) D:\Projects\git>git clone --recursive https://github.com/DrKLO/Telegram.git Cloning into 'Telegram'... remote: Counting objects: 21342, done. remote: Compressing objects: 100% (2/2), done. remote: Total 21342 (delta 0), reused 0 (delta 0), pack-reused 21340 Receiving objects: 100% (21342/21342), 119.09 MiB | 2.09 MiB/s, done. Resolving deltas: 100% (11442/11442), done. Checking connectivity... done. Checking out files: 100% (3977/3977), done. Submodule 'TMessagesProj/jni/libtgvoip' ( https://github.com/grishka/libtgvoip) registered for path 'TMessagesProj/jni/libtgvoip' Cloning into 'TMessagesProj/jni/libtgvoip'... remote: Counting objects: 886, done. remote: Compressing objects: 100% (45/45), done. remote: Total 886 (delta 15), reused 26 (delta 11), pack-reused 828 Receiving objects: 100% (886/886), 7.41 MiB | 1.81 MiB/s, done. Resolving deltas: 100% (450/450), done. Checking connectivity... done. Submodule path 'TMessagesProj/jni/libtgvoip': checked out 'de33700312e3676a520b5a79d51e953fcf23cf51'

2: In the environment variables: Set ANDROID_HOME to the path of the Android SDK 3: Using Android Studio SDK Manager download and install NDK (Tools->Android->SDK Manafer -> SDK-Tools->NDK) 4: Install Gradle from gradle.org. The current version is 4.0.1. check the installation by issuing gradle -v 5: Build the gradle wrapper gradle wrapper --gradle-version 4.0.1 6: Build Telegram: In D:\Projects\git>cd Telegram, and then D:\Projects\git\Telegram> gradlew build

When you reach this step, gradle tells you what is missing/wrong. So you can go after them one by one and fix them. They are mainly the keys I told in previous email. Or the files that should be created to contain those keys

Have a nice time! Javad

On Sun, Jul 9, 2017 at 3:15 PM, Viktor Oreshkin notifications@github.com wrote:

@dsmanhaes https://github.com/dsmanhaes What if you define TGVOIP_NO_DSP? WebRtcAgcfree seems to be defined in webrtc/modules/audio processing/agc/legacy/gain_control.h, and it's included only if TGVOIP_NO_DSP is undefined. At least that's what looking into sources for 7 minutes suggests.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/grishka/libtgvoip/issues/8#issuecomment-313919293, or mute the thread https://github.com/notifications/unsubscribe-auth/ABeCLNVk7YXgWS26PFPYMg_dmM-qjWveks5sMNKCgaJpZM4NDee7 .

papmodern commented 7 years ago

I failed to compile the 3.18 version at all. Now I'm updating the project to 4.1 and do what you said @javadch.

But here is new error in ndk-build:

make: *** No rule to make target C:/Users/myuser/Documents/Temp/telegram-source/Telegram/TMessagesProj/jni/./libtgvoip/audio/Resampler.cpp', needed by C:/Users/myuser/Documents/Temp/telegram-source/Telegram/TMessagesProj/build/intermediates/ndkBuild/armv7/debug/obj/local/armeabi-v7a/objs-debug/voip/./libtgvoip/audio/Resampler.o'. Stop.

God I'm really tired :((

saeedhei commented 6 years ago

@javadch I did your Steps and I got This Error:

 [armeabi-v7a] SharedLibrary  : libtmessages.29.so
  D:/TG/Telegram/TMessagesProj/jni/./ffmpeg/armv7-a/libavutil.a(mem.o):mem.c:function av_malloc: error: undefined reference to 'posix_memalign'
  collect2.exe: error: ld returned 1 exit status

make: *** [D:/TG/Telegram/TMessagesProj/build/intermediates/ndkBuild/afat/debug/obj/local/armeabi-v7a/libtmessages.29.so] Error 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org
grishka commented 6 years ago

The prebuilt ffmpeg in the Android app isn't compatible with the latest NDK. You need to use an older NDK version. Everything works fine for me with 16.1.4479499.

saeedhei commented 6 years ago

Finally it Builted TMessagesProj-x64_SDK23-release.apk and that is 16 mb but telegram 4.9.1 in my phone is 54 mb, is That Correct? Because when I want to open apk that say: This app isn't compatible with your phone. My Phone is samsung galaxy j7 prime2. what Flavors Should I Choose?

grishka commented 6 years ago

what Flavors Should I Choose

armv7 or arm64. Or afat to include native libraries for all CPUs in a single apk.

BaiXiaoYan commented 6 years ago

How can fix this error?

Caused by: java.lang.RuntimeException: GNUMAKE: Expected exactly one source file in compile step: com.android.build.gradle.external.gnumake.CommandClassifier$NativeCompilerBuildTool@7e732c0e but received: '-DVERSION=1.3.1' .../Telegram/TMessagesProj/jni/./exoplayer/libFLAC/bitmath.c

...

Could you help me please? Thanks.

saeedhei commented 6 years ago

I did these steps: (https://stackoverflow.com/questions/52017879/tmessagesprojexternalnativebuildafatdebug)

BaiXiaoYan commented 6 years ago

Thank you.