termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
12.99k stars 2.99k forks source link

[Bug]: Bug in cmake #19058

Closed defencedog closed 7 months ago

defencedog commented 7 months ago

Problem description

cmake is unusable

~ $ cmake --help                                        CANNOT LINK EXECUTABLE "cmake": cannot locate symbol "_ZN4Json5ValueC1ERKNSt6__ndk112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE" referenced by "/data/data/com.termux/files/usr/bin/cmake"...

What steps will reproduce the bug?

Install cmake & it gives this error

What is the expected behavior?

Cannot use cmake....

System information

termux-info:

Termux Variables:                                       TERMUX_API_VERSION=0.50.1                               TERMUX_APK_RELEASE=F_DROID                              TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=10505                                    TERMUX_IS_DEBUGGABLE_BUILD=0                            TERMUX_MAIN_PACKAGE_FORMAT=debian                       TERMUX_VERSION=0.118.0                                  TERMUX__USER_ID=0                                       Packages CPU architecture:
arm                                                     Subscribed repositories:                                # sources.list                                          deb https://md.mirrors.hacktegic.com/termux/termux-main stable main                                             # tur-repo (sources.list.d/tur.list)                    deb https://tur.kcubeterm.com tur-packages tur tur-on-device tur-continuous
Updatable packages:                                     All packages up to date                                 termux-tools version:                                   1.40.5                                                  Android version:                                        13                                                      Kernel build information:                               Linux localhost 4.19.191-25884040-abA137FXXS3CWL2 #1 SMP PREEMPT Fri Dec 8 18:11:03 KST 2023 armv8l Android     Device manufacturer:                                    samsung                                                 Device model:                                           SM-A137F                                                LD Variables:                                           LD_LIBRARY_PATH=/system/lib                             LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so                                                Installed termux plugins:                               com.termux.api versionCode:51
truboxl commented 7 months ago

Please do not set LD_LIBRARY_PATH=/system/lib

defencedog commented 7 months ago

@truboxl I added that because ffmpeg will not work Your instructions work ... but now when I use ffmpeg

CANNOT LINK EXECUTABLE "ffmpeg": cannot locate symbol "_Z17createHeifDecoderv" referenced by "/system/lib/libhwui.so"...
truboxl commented 7 months ago

Please install libandroid-stub if it fixes your issue

defencedog commented 7 months ago

Thanks it works...

Biswa96 commented 7 months ago

May I ask how libandroid-stub fixed the ffmpeg issue? Ther error output has createHeifDecoder function which is not related to libandroid library.

sylirre commented 7 months ago

It is related but indirectly. libandroid.so has dependencies such as libhwui.so, the latter fails to resolve symbol due to library conflict - Termux have libraries with same name as Android, but they different internally causing stuff to break.

This is also why one should never set LD_LIBRARY_PATH in Termux. It messes up library search order. This variable was required for Termux running on legacy Android versions (5.x, 6.x).

Installing libandroid-stub cause ffmpeg to pick a stub version of libandroid.so that is present in Termux directories instead of Android system.

agnostic-apollo commented 7 months ago

The _Z17createHeifDecoderv symbol is provided by /system/lib[64]/libheif.so, which /system/lib[64]/libhwui.so depends on.

The termux libheif package also provides $PREFIX/lib/libheif.so.

Installing the libandroid-stub package shouldn't be required, my guess is that user has set LD_LIBRARY_PATH=/data/data/com.termux/files/usr/lib somewhere else, which causes $PREFIX/lib/libheif.so to be picked up instead of the system one.

This error was posted in https://www.reddit.com/r/termux/comments/17pxvw5/how_to_fix_this/ as well and unsetting LD_LIBRARY_PATH worked.

defencedog commented 7 months ago

@agnostic-apollo Problem has resurfaced with gtt. I had already installed libandroid-stub

CANNOT LINK EXECUTABLE "gtt": cannot locate symbol "_Z17createHeifDecoderv" referenced by "/system/lib/libhwui.so"...
truboxl commented 7 months ago

Can you help try rm $PREFIX/lib/libheif.so?

defencedog commented 7 months ago

@truboxl will not rm be dangerous what about renaming via mv?

truboxl commented 7 months ago

Unless you use packages from apt rdepends libheif then maybe. You can always restore by apt reinstall libheif.

agnostic-apollo commented 7 months ago

Also post output of echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH after running it in the same shell in which error is triggered.

defencedog commented 7 months ago

Also post output of echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH after running it in the same shell in which error is triggered.

LD_LIBRARY_PATH=/data/data/com.termux/files/usr/lib:/data/data/com.termux/files/usr/local/lib

agnostic-apollo commented 7 months ago

That is your problem, find out where it is being set and remove the command, it should be empty on Android >= 7, termux does not set it by default. Also uninstall libandroid-stub with apt remove libandroid-stub and restore your $PREFIX/lib/libheif.so file.