T
Termux4w ago
bsd.us

Cargo rust build fail

Hello, actually I don't know if that makes sense to try but I wanted to install this project https://github.com/marin-m/SongRec on termux And after a few commands :
pkg install openssh build-essential rust
cargo install songrec --no-default-features
pkg install openssh build-essential rust
cargo install songrec --no-default-features
I'm having a compilation error I can't find a fix for I attached the error as a file here Any ideas what I'm missing ? thank you for your time
GitHub
GitHub - marin-m/SongRec: An open-source Shazam client for Linux, w...
An open-source Shazam client for Linux, written in Rust. - marin-m/SongRec
23 Replies
Catinette
Catinette4w ago
you should do RUST_BACKTRACE=1 cargo install etc then show it here someone might be able to help
FalconSN
FalconSN4w ago
bsd.us
bsd.usOP4w ago
I did pkg install binutils-bin then ran again with RUST_BACKTRACE this time, seems like the same error
FalconSN
FalconSN4w ago
Do you have ld in PATH? Oh, I think it's lld that provides ld Just type ld in terminal and install the one it recommends
bsd.us
bsd.usOP4w ago
sorry I didn't realize ld was a command, just made it (the ld tool) answer by doing pkg install binutils (without -bin behind) trying again the build
bsd.us
bsd.usOP4w ago
damn actually this one is so long I don't even have the beginning of it I removed backtrace because I thought it was causing it but no I managed to make it go a bit further with pkg install libacl (a line in the log said it was missing) But I have more errors...
komo
komo4w ago
you'll need to patch that the source code contains some functions that aren't available in the bionic libc such as pthread_cancel for example you either want it to be packaged, so you don't need extra hassle to use it, or you can patch it yourself
bsd.us
bsd.usOP3w ago
thank you for your answer, so you're saying this bionic libc a specific one for termux or to aarch64 ? I don't know anything about rust, patching it myself sounds ambitious... I'm going to check these methods maybe I can find packages to support it, if that was what you were suggesting to do else
FalconSN
FalconSN3w ago
Specific to Android
owokitty
owokitty3w ago
error message of this build:
/data/data/com.termux/files/usr/tmp/cargo-installGQvJLD/release/build/gettext-sys-972d75247abaeb19/out/gettext/gettext-runtime/intl/bindtextdom.c:91:3: error: use of undeclared identifier 'pthread_cancel'; did you mean 'pthread_once'?
/data/data/com.termux/files/usr/tmp/cargo-installGQvJLD/release/build/gettext-sys-972d75247abaeb19/out/gettext/gettext-runtime/intl/bindtextdom.c:91:3: error: use of undeclared identifier 'pthread_cancel'; did you mean 'pthread_once'?
technically, from a certain perspective, this software is already prepatched here, https://github.com/termux/termux-packages/blob/8c8b7ea67ded9c969d9f7e7de7425744ff5de151/ndk-patches/libintl.h#L35 but from the perspective of the gettext-sys cargo crate, it's not, and somehow, it can't find that by itself failing code (Android-unaware Rust): https://github.com/gettext-rs/gettext-rs/blob/c15b78f5ad8a5e5f9a117ff4c0e785ded0b124f6/gettext-sys/build.rs#L100-L129 Documentation: https://github.com/gettext-rs/gettext-rs/tree/master/gettext-sys#environment-variables how to force a build of this app to complete:
pkg upgrade
pkg remove ndk-multilib # if you have this, it will somehow conflict
pkg install gettext
export GETTEXT_DIR="$PREFIX"
# this part is hard to explain but basically it compiles the libintl.h into a libintl.a that -lintl works on
sed -e 's/__inline__//g' -e 's/^static//g' $PREFIX/include/libintl.h | clang -O0 -x c -c -o libintl.o -
ar cru $PREFIX/lib/libintl.a libintl.o
# force -lc++_static to link to libc++_shared.so instead (oboe-sys problem)
echo 'INPUT(-lc++_shared)' > $PREFIX/lib/libc++_static.so
cargo install songrec --no-default-features
pkg upgrade
pkg remove ndk-multilib # if you have this, it will somehow conflict
pkg install gettext
export GETTEXT_DIR="$PREFIX"
# this part is hard to explain but basically it compiles the libintl.h into a libintl.a that -lintl works on
sed -e 's/__inline__//g' -e 's/^static//g' $PREFIX/include/libintl.h | clang -O0 -x c -c -o libintl.o -
ar cru $PREFIX/lib/libintl.a libintl.o
# force -lc++_static to link to libc++_shared.so instead (oboe-sys problem)
echo 'INPUT(-lc++_shared)' > $PREFIX/lib/libc++_static.so
cargo install songrec --no-default-features
GitHub
termux-packages/ndk-patches/libintl.h at 8c8b7ea67ded9c969d9f7e7de7...
A package build system for Termux. Contribute to termux/termux-packages development by creating an account on GitHub.
GitHub
gettext-rs/gettext-sys at master · gettext-rs/gettext-rs
GNU Gettext FFI binding for Rust. Contribute to gettext-rs/gettext-rs development by creating an account on GitHub.
GitHub
gettext-rs/gettext-sys/build.rs at c15b78f5ad8a5e5f9a117ff4c0e785de...
GNU Gettext FFI binding for Rust. Contribute to gettext-rs/gettext-rs development by creating an account on GitHub.
owokitty
owokitty3w ago
however the gettext-related problem is only one of the problems here. This app depends on the oboe-sys crate
owokitty
owokitty3w ago
and it is an audio app, so basically you need the audio part to work which the oboe-sys crate is necessary for, and unfortunately, I have not been able to get the audio of any app that uses the oboe-sys crate to work. you will see some more errors if you try to run the build I showed how to force above. those other errors basically come from the oboe-sys crate. I have been able to successfully force the GUI parts of GUI rust apps that attempted to pull in the oboe-sys crate to run before, by heavily patching the app until its audio was completely disabled. and then I was able to see the GUI. Example:
owokitty
owokitty3w ago
GitHub
blocktopograph, a bevy engine hello world in termux · termux-user-...
- very buggy - crashes 6 out of every 7 times i launch it, but stays running the 7th time - audio backend is disabled
owokitty
owokitty3w ago
however, this is not a GUI app and it's an app that is centered around Audio functionality anyway, so that wouldn't be helpful here In order to make this app work in Termux, the next steps would be to try to figure out if there is any way to either fix the oboe-sys crate to work in Termux (which seems very hard for me and maybe someone else can figure out how to do it), or maybe find some way to, instead of allowing it to default to the oboe-syscrate, divert it to get the app to use one of the audio APIs that already works in Termux, like Portaudio, Pulseaudio, OpenAL, or OpenSLES Some functionality of the program might still work from that build, though, ^ i'm not sure how much. you could try it and check, for me, the songrec audio-file-to-fingerprint , songrec audio-file-to-recognized-song and songrec help subcommands seem to work the songrec listen, songrec recognize and songrec microphone-to-recognized-song subcommands all produce the error i've seen before in other programs that attempt to run the oboe-sys crate
thread '<unnamed>' panicked at /data/data/com.termux/files/home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ndk-context-0.1.1/src/lib.rs:72:30:
android context was not initialized
stack backtrace:
0: 0x58a1fb9450 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hf3165a890b3f99a7
1: 0x58a1fef6ec - core::fmt::write::h508e32b073fc24c7
2: 0x58a1fb8380 - std::io::Write::write_fmt::hec73da2da261f297
3: 0x58a1fb9350 - std::sys::backtrace::BacktraceLock::print::hb683b8d74ca6376a
4: 0x58a1fd671c - std::panicking::default_hook::{{closure}}::h8dd0451103712394
5: 0x58a1fd657c - std::panicking::default_hook::hedb963aceca4abf9
6: 0x58a1fd7130 - std::panicking::rust_panic_with_hook::hf43d358058db0558
7: 0x58a1fb9acc - std::panicking::begin_panic_handler::{{closure}}::hc765cd251c62ee61
8: 0x58a1fb990c - std::sys::backtrace::__rust_end_short_backtrace::h28b56892d3980e5c
9: 0x58a1fd6bc4 - rust_begin_unwind
10: 0x58a1fedfb0 - core::panicking::panic_fmt::he5d7e6884ef83b14
11: 0x58a1febab8 - core::option::expect_failed::h2f9f24111c147b51
12: 0x58a1d86570 - ndk_context::android_context::h4a90086c4b132970
13: 0x58a1d86040 - oboe::java_interface::devices_info::<impl oboe::java_interface::definitions::AudioDeviceInfo>::request::h00676c51c08870aa
14: 0x58a1d73c9c - <cpal::host::oboe::Host as cpal::traits::HostTrait>::devices::hf1d654f699fb21bb
15: 0x58a1d69424 - <cpal::platform::platform_impl::Host as cpal::traits::HostTrait>::devices::h90c7751d1fed1ae4
16: 0x58a1cbe8c8 - <songrec::audio_controllers::cpal::CpalBackend as songrec::audio_controllers::audio_backend::AudioBackend>::list_devices::h279abff58988bcef
17: 0x58a1cc8040 - songrec::core::microphone_thread::microphone_thread::hd1646beb8945a853
18: 0x58a1cd9ac8 - std::sys::backtrace::__rust_begin_short_backtrace::h29d54b7136a6a779
19: 0x58a1cdae5c - core::ops::function::FnOnce::call_once{{vtable.shim}}::h4d0fdbb21b8c3ea0
20: 0x58a1fd8338 - std::sys::pal::unix::thread::Thread::new::thread_start::ha726c1c05382f58a
21: 0x776386b3b4 - _ZL15__pthread_startPv
22: 0x77638080bc - __start_thread
thread '<unnamed>' panicked at /data/data/com.termux/files/home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ndk-context-0.1.1/src/lib.rs:72:30:
android context was not initialized
stack backtrace:
0: 0x58a1fb9450 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hf3165a890b3f99a7
1: 0x58a1fef6ec - core::fmt::write::h508e32b073fc24c7
2: 0x58a1fb8380 - std::io::Write::write_fmt::hec73da2da261f297
3: 0x58a1fb9350 - std::sys::backtrace::BacktraceLock::print::hb683b8d74ca6376a
4: 0x58a1fd671c - std::panicking::default_hook::{{closure}}::h8dd0451103712394
5: 0x58a1fd657c - std::panicking::default_hook::hedb963aceca4abf9
6: 0x58a1fd7130 - std::panicking::rust_panic_with_hook::hf43d358058db0558
7: 0x58a1fb9acc - std::panicking::begin_panic_handler::{{closure}}::hc765cd251c62ee61
8: 0x58a1fb990c - std::sys::backtrace::__rust_end_short_backtrace::h28b56892d3980e5c
9: 0x58a1fd6bc4 - rust_begin_unwind
10: 0x58a1fedfb0 - core::panicking::panic_fmt::he5d7e6884ef83b14
11: 0x58a1febab8 - core::option::expect_failed::h2f9f24111c147b51
12: 0x58a1d86570 - ndk_context::android_context::h4a90086c4b132970
13: 0x58a1d86040 - oboe::java_interface::devices_info::<impl oboe::java_interface::definitions::AudioDeviceInfo>::request::h00676c51c08870aa
14: 0x58a1d73c9c - <cpal::host::oboe::Host as cpal::traits::HostTrait>::devices::hf1d654f699fb21bb
15: 0x58a1d69424 - <cpal::platform::platform_impl::Host as cpal::traits::HostTrait>::devices::h90c7751d1fed1ae4
16: 0x58a1cbe8c8 - <songrec::audio_controllers::cpal::CpalBackend as songrec::audio_controllers::audio_backend::AudioBackend>::list_devices::h279abff58988bcef
17: 0x58a1cc8040 - songrec::core::microphone_thread::microphone_thread::hd1646beb8945a853
18: 0x58a1cd9ac8 - std::sys::backtrace::__rust_begin_short_backtrace::h29d54b7136a6a779
19: 0x58a1cdae5c - core::ops::function::FnOnce::call_once{{vtable.shim}}::h4d0fdbb21b8c3ea0
20: 0x58a1fd8338 - std::sys::pal::unix::thread::Thread::new::thread_start::ha726c1c05382f58a
21: 0x776386b3b4 - _ZL15__pthread_startPv
22: 0x77638080bc - __start_thread
komo
komo3w ago
@owokitty did you manage to patch that softwares that used oboe-sys crate?
owokitty
owokitty3w ago
it depends what you mean, so far I have not been able to get any app that uses oboe-sys crate to have working speaker/microphone connection. i have only been able to force-build them, and get partial functionality (the parts that do not use speaker or microphone)
bsd.us
bsd.usOP3w ago
thank you so much for digging this up ! I struggled a bit with my old phone running out of space, but your commands to force build did work ! Actually from the start I didn't even imagine being able to record with termux directly, as you are talking about on the audio part of the program ! Of course it would be ideal but I'm afraid I don't have enough knowledge to continue researches, but thanks to you it might one day work On my side I will open an issue on songrec to suggest adding support for termux as it would really be useful there seem to be an issue on termux which is not there on linux with m4a files, seems to work well with mp3 though
owokitty
owokitty3w ago
I see, you can use ffmpeg to convert anything you need to MP3 if needed and, if it works for you, there are several ways to record audio to files with microphone in termux, the easiest way is the termux-microphone-record command, to enable it you would just need to install the Termux:API app, and then grant microphone permission to this app manually in Android settings, then Termux will be able to record from microphone recording apps that do work, from there you could possibly make a script to record a file and then convert it to MP3, and then pass the file to songrec
bsd.us
bsd.usOP3w ago
my record app was able to record mp3 files, so doing "open with" termux I can bring the file in termux and use the command, easy does it ! Concerning the issue here it is, I hope I will get some attention: https://github.com/marin-m/SongRec/issues/195
GitHub
[Feature Request] Termux support · Issue #195 · marin-m/SongRec
Hello, this issue follows the discussion someone created a few days ago here As this gave me hope this could be a feature in future builds All the following was found on Termux&#39;s discord and in...

Did you find this page helpful?