The error CANNOT LINK EXECUTABLE "./openconnect": library "libopenconnect.so" not found on x86-64 LineageOS Termux—despite the file libopenconnect.so being present—is a classic dynamic linker issue. Here’s a structured breakdown of the problem and how to resolve it:
The dynamic linker (ld) cannot find libopenconnect.so because:
/system/lib64, /vendor/lib64, or Termux’s $PREFIX/lib).ldd Fails to Find Itldd uses the same search paths as the dynamic linker.libopenconnect.so is in the same directory as the openconnect binary, the linker will not look there unless explicitly told to do so.LD_LIBRARY_PATHTemporarily tell the linker where to find the library:
bashexport LD_LIBRARY_PATH=$(pwd):$LD_LIBRARY_PATH ./openconnect
-rpath During CompilationIf you compiled openconnect yourself, ensure the library path is embedded in the binary:
bashgcc -o openconnect openconnect.c -lopenconnect -Wl,-rpath=$(pwd)
-rpath embeds the library path into the executable, so the linker will look there at runtime.Copy libopenconnect.so to a directory in the default linker search path:
bashcp libopenconnect.so $PREFIX/lib
$PREFIX is usually /data/data/com.termux/files/usr.ldconfig (if available) to update the linker cache:
bashldconfig
If you don’t want to move the library, you can symlink it to a standard path:
bashln -s $(pwd)/libopenconnect.so $PREFIX/lib/libopenconnect.so
Ensure the library is readable:
bashchmod +r libopenconnect.so
libopenconnect.so is x86-64 (as per file output).openconnect binary are also x86-64.libopenconnect.so.Even if libopenconnect.so is found, it may depend on other libraries. Use:
bashldd libopenconnect.so
pkg install in Termux).$PREFIX). Libraries should ideally be placed in $PREFIX/lib.openconnect via pkg install openconnect, the package should have placed the library in the correct location. If not, reinstall it:
bashpkg reinstall openconnect
Check where the linker looks for libraries:
bashgetconf -a | grep LD_LIBRARY_PATH
or
bashenv | grep LD_LIBRARY_PATH
List all library paths:
bashcat /etc/ld.so.conf ldconfig -p
Run with verbose linker output:
bashLD_DEBUG=libs ./openconnect
libopenconnect.so.LD_LIBRARY_PATH or use -rpathexport LD_LIBRARY_PATH=$(pwd):$LD_LIBRARY_PATHpkg install$PREFIX/lib$PREFIX/libNext Step:
Try export LD_LIBRARY_PATH=$(pwd):$LD_LIBRARY_PATH and rerun ./openconnect. If that works, you can make it permanent by adding it to your ~/.bashrc. If not, let me know the output of LD_DEBUG=libs ./openconnect for further debugging.