termux / termux-app

Termux - a terminal emulator application for Android OS extendible by variety of packages.
https://f-droid.org/en/packages/com.termux
Other
36.33k stars 3.82k forks source link

library "libc++_shared.so" not found #1436

Closed twoplan closed 4 years ago

twoplan commented 4 years ago

I try to compile a chess engine for usage inside an Android chess gui.

The chess engine compiles fine with clang 9. And it works well at the shell inside Termux. Unfortunately the Android chess gui can't load the engine. Log shows:

CANNOT LINK EXECUTABLE "./DefenChess_2.2": library "libc++_shared.so" not found
Aborted

So I tried to compile the engine with option -static. Get now this error from the linker:

clang++ -DNDEBUG -Wall -Wcast-qual -Wextra -Wshadow -pedantic -std=c++11  -O3 -flto -static -march=armv8-a bitboard.o data.o eval.o move.o move_utils.o params.o position.o pst.o search.o see.o target.o test.o timecontrol.o thread.o tt.o tune.o uci.o magic.o main.o movegen.o tb.o fathom/tbprobe.o -o Defenchess_2.2 -pthread
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: cannot find -lc++_shared
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: cannot find -lm
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: cannot find -lc
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:43: release] Error 1

Pretty sure that I'm (new to Termux and Android) missing something.

$ termux-info

Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://termux.org/packages/ stable main
# science-repo (sources.list.d/science.list)
deb https://dl.bintray.com/grimler/science-packages-24 science stable
# game-repo (sources.list.d/game.list)
deb https://dl.bintray.com/grimler/game-packages-24 games stable
Updatable packages:
All packages up to date
Android version:
7.0
Kernel build information:
Linux localhost 3.10.84-14953299 #1 SMP PREEMPT Thu Jun 27 19:00:41 KST 2019 aarch64 Android
Device manufacturer:
samsung
Device model:
SM-T813

$ clang++ -v

clang version 9.0.1
Target: aarch64-unknown-linux-android
Thread model: posix
InstalledDir: /data/data/com.termux/files/usr/bin
ghost commented 4 years ago
  1. Don't use -static.
  2. Ensure that program is built with runpath. LDFLAGS: -Wl,-rpath=/data/data/com.termux/files/usr/lib,--enable-new-dtags
Grimler91 commented 4 years ago

Problem is that the "chess gui" is another app, so -Wl,-rpath=/data/data/com.termux/files/usr/lib,--enable-new-dtags won' help here unfortunately

twoplan commented 4 years ago

Thanks, does it mean Termux can't be used to compile (c|c++|d|go|rust) chess engines for an Android gui app?

ghost commented 4 years ago

It means that build tools are targeted at Termux environment first.

When using binary compiled in Termux in another application, make sure that all its dependencies are copied too.