LagPixelLOL / ChatGPTCLIBot

ChatGPT Bot in CLI with long term memory support using Embeddings.
MIT License
340 stars 38 forks source link

Building in Termux(android) #15

Closed Happ1ness-dev closed 1 year ago

Happ1ness-dev commented 1 year ago

Hi, is it possible to build this project in termux?

After an hour of trying, I managed to build it, but it crashed upon running. I also tried to build it in proot, but got lots of errors.

I've lost hope, honestly.

Edit: Fixed, see this comment.

LagPixelLOL commented 1 year ago

What's the error message when it crashed?

Happ1ness-dev commented 1 year ago

What's the error message when it crashed?

terminating with uncaught exception of type std::bad_cast: std::bad_cast
Aborted
Happ1ness-dev commented 1 year ago

And here's the output of debugger, if it helps (gpt-4 advised me to do it xD):

~/.../ChatGPTCLIBot/build $ gdb ./GPT3Bot
GNU gdb (GDB) 13.1
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "aarch64-linux-android".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./GPT3Bot...
(gdb) run
Starting program: /data/data/com.termux/files/home/git-projects/ChatGPTCLIBot/build/GPT3Bot
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/data/data/com.termux/files/usr/lib/libthread_db.so".
warning: section .note.gnu.build-id not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so
warning: section .note.gnu.property not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so
warning: section .dynsym not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so
warning: section .gnu.version not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so
warning: section .gnu.version_d not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so
warning: section .gnu.hash not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so
warning: section .dynstr not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so
warning: section .rela.plt not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so
warning: section .eh_frame_hdr not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so
warning: section .eh_frame not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so
warning: section .plt not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so
warning: section .dynamic not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so
warning: section .got.plt not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so
warning: section .bss not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libdl.so
warning: section .note.android.ident not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .note.gnu.build-id not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .note.gnu.property not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .dynsym not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .gnu.version not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .gnu.version_d not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .gnu.version_r not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .gnu.hash not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .dynstr not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .rela.dyn not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .relr.dyn not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .rela.plt not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .rodata not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .eh_frame_hdr not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .eh_frame not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .plt not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .data.rel.ro not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .fini_array not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .dynamic not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .got not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .got.plt not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .data not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .bss not found in .gnu_debugdata for /apex/com.android.runtime/lib64/bionic/libm.so
warning: section .note.android.ident not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .note.gnu.build-id not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .note.gnu.property not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .dynsym not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .gnu.version not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .gnu.version_r not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .gnu.hash not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .dynstr not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .rela.dyn not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .relr.dyn not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .rela.plt not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .rodata not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .eh_frame_hdr not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .eh_frame not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .plt not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .data.rel.ro not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .fini_array not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .dynamic not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .got not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .got.plt not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .data not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .bss not found in .gnu_debugdata for /system/lib64/libnetd_client.so
warning: section .note.android.ident not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .note.gnu.build-id not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .note.gnu.property not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .dynsym not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .gnu.version not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .gnu.version_r not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .gnu.hash not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .dynstr not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .rela.dyn not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .relr.dyn not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .rela.plt not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .rodata not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .gcc_except_table not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .eh_frame_hdr not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .eh_frame not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .plt not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .data.rel.ro not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .fini_array not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .init_array not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .dynamic not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .got not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .got.plt not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .data not found in .gnu_debugdata for /system/lib64/libc++.so
warning: section .bss not found in .gnu_debugdata for /system/lib64/libc++.so
terminating with uncaught exception of type std::bad_cast: std::bad_cast

Program received signal SIGABRT, Aborted.
0x0000007fefcb2a28 in abort () from /apex/com.android.runtime/lib64/bionic/libc.so
(gdb) bt
#0  0x0000007fefcb2a28 in abort () from /apex/com.android.runtime/lib64/bionic/libc.so
#1  0x00000055556c4014 in abort_message (format=<optimized out>)
    at /buildbot/src/android/ndk-r25-release/toolchain/llvm-project/libcxx/../../../toolchain/llvm-project/libcxxabi/src/abort_message.cpp:76
#2  0x00000055556c4240 in demangling_terminate_handler ()
    at /buildbot/src/android/ndk-r25-release/toolchain/llvm-project/libcxx/../../../toolchain/llvm-project/libcxxabi/src/cxa_default_handlers.cpp:62
#3  0x00000055556c40cc in std::__terminate (func=0x0)
    at /buildbot/src/android/ndk-r25-release/toolchain/llvm-project/libcxx/../../../toolchain/llvm-project/libcxxabi/src/cxa_handlers.cpp:59
#4  0x00000055556c366c in __cxxabiv1::failed_throw (
    exception_header=exception_header@entry=0xb400007fed60a000)
    at /buildbot/src/android/ndk-r25-release/toolchain/llvm-project/libcxx/../../../toolchain/llvm-project/libcxxabi/src/cxa_exception.cpp:152
#5  0x00000055556c35c4 in __cxa_throw (thrown_object=0xb400007fed60a080,
    tinfo=0x55556e7a58 <typeinfo for std::bad_cast>, dest=0x55556db1c4 <std::bad_cast::~bad_cast()>)
    at /buildbot/src/android/ndk-r25-release/toolchain/llvm-project/libcxx/../../../toolchain/llvm-project/libcxxabi/src/cxa_exception.cpp:283
#6  0x00000055556397f0 in std::__ndk1::__throw_bad_cast() ()
#7  0x00000055556a751c in std::__ndk1::locale::__imp::use_facet (id=-4148298068163643485,
    this=<optimized out>)
    at /buildbot/src/android/ndk-r25-release/toolchain/llvm-project/libcxx/src/locale.cpp:472
#8  std::__ndk1::locale::use_facet (this=<optimized out>, x=...)
    at /buildbot/src/android/ndk-r25-release/toolchain/llvm-project/libcxx/src/locale.cpp:605
#9  0x0000007ff2cb1d80 in ?? () from /data/data/com.termux/files/usr/lib/libc++_shared.so
#10 0x0000007ff2cb16c0 in std::__ndk1::DoIOSInit::DoIOSInit() ()
   from /data/data/com.termux/files/usr/lib/libc++_shared.so
#11 0x0000007ff2cb2af4 in ?? () from /data/data/com.termux/files/usr/lib/libc++_shared.so
#12 0x0000007ff7f1dbb8 in __dl__ZN6soinfo17call_constructorsEv () from /system/bin/linker64
#13 0x0000007ff7f1d9d8 in __dl__ZN6soinfo17call_constructorsEv () from /system/bin/linker64
#14 0x0000007ff7f1d9d8 in __dl__ZN6soinfo17call_constructorsEv () from /system/bin/linker64
#15 0x0000007ff7f1d9d8 in __dl__ZN6soinfo17call_constructorsEv () from /system/bin/linker64
#16 0x0000007ff7f1d9d8 in __dl__ZN6soinfo17call_constructorsEv () from /system/bin/linker64
#17 0x0000007ff7f83e4c in __dl__ZL29__linker_init_post_relocationR19KernelArgumentBlockR6soinfo ()
   from /system/bin/linker64
#18 0x0000007ff7f82da4 in __dl___linker_init () from /system/bin/linker64
#19 0x0000007ff7f2066c in __dl__start () from /system/bin/linker64
LagPixelLOL commented 1 year ago

can you debug to the line where that exception is thrown? maybe put a std::cout before and after this line of code and see what happens.

Happ1ness-dev commented 1 year ago

can you debug to the line where that exception is thrown? maybe put a std::cout before and after this line of code and see what happens.

Tbh, I'm not really familiar with debugging, and besides that, I've already deleted the project directory (with all the changes needed for it to compile) 🤦

LagPixelLOL commented 1 year ago

RIP😞

Happ1ness-dev commented 1 year ago

can you debug to the line where that exception is thrown? maybe put a std::cout before and after this line of code and see what happens.

Ok, I've made the changes and built the project. I get the same error:

terminating with uncaught exception of type std::bad_cast: std::bad_cast
Aborted
LagPixelLOL commented 1 year ago

no output in terminal? the only 2 lines of code before it are the exit hook and curl global init, if these 2 can't be run, then probably impossible to fix.

Happ1ness-dev commented 1 year ago

no output in terminal? the only 2 lines of code before it are the exit hook and curl global init, if these 2 can't be run, then probably impossible to fix.

It seems so. Sad.

Happ1ness-dev commented 1 year ago

I'm just so confused. Is this an issue with some external library, or the project?

Happ1ness-dev commented 1 year ago

I managed to successfully build and run it in proot Screenshot_2023-05-14-12-33-48-323_com termux

Happ1ness-dev commented 1 year ago

Yeah, seems to work fine Screenshot_2023-05-14-12-37-55-510_com termux

Happ1ness-dev commented 1 year ago

Ok, so for anyone interested in building this project for termux (in proot), here's how I done it:

# install vcpkg
cd $HOME
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg/ && ./bootstrap-vcpkg.sh -disableMetrics

Now we need to setup things for vcpkg. I've done it just in case, because it failed for me previously, without these steps. I also maybe doing it wrong, or maybe it's the way to setup vcpkg, correct me if I'm wrong. (It's literally my first time using it)

Open your .bashrc and add the following lines to it:

# setup vcpkg
export VCPKG_FORCE_SYSTEM_BINARIES=arm
export VCPKG_ROOT=$HOME/vcpkg
export PATH=$PATH:$VCPKG_ROOT

You may need to re-login or just source the .bashrc:

source ~/.bashrc

Now we're ready to build the project.

### Assuming that you've already cloned the project and are in it's directory ###

# configure things 
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake

# and build
cmake --build build/

P.S. Keep in mind, that I'm not a professional in this, and I can't guarantee that these instructions would work for everyone.

LagPixelLOL commented 1 year ago

Congraz!

24rr commented 1 year ago

should I run this on proot? How can I?

Happ1ness-dev commented 1 year ago

should I run this on proot? How can I?

Install proot and proot-distro, you can then install Ubuntu or any other distro available there, and log into it.

24rr commented 1 year ago

should I run this on proot? How can I?

Install proot and proot-distro, you can then install Ubuntu or any other distro available there, and log into it.

Do you have a Discord? My friend can’t even build it on Termux.

Happ1ness-dev commented 1 year ago

@editor-syntax I do, but I'm not your personal technical support. Don't even try to build it in termux without proot, it's a lost cause.