Android Question Assistance With Adding libc++_shared.so

Tyler

Member
Licensed User
Longtime User
Hello All,

I've built the llama-cli binaries using Make in Termux and I'm trying to get them to run in my B4A app.

The issue I'm running into is I keep getting an error that I'm missing libcc++:

Error:
Err: CANNOT LINK EXECUTABLE "/data/user/0/b4a.example/files/llama.cpp/llama-cli": library "libc++_shared.so" not found: needed by main executable

relevant code:
    Dim p as Phone
    Dim command1 As String
    command1 = File.DirInternal & "/llama.cpp/llama-cli"

    Wait For (p.ShellAsync(command1, Array As String("-m"))) Complete (Success As Boolean, ExitValue As Int, StdOut As String, StdErr As String)
    If Success Then
        Log(ExitValue)
        Log("Out: " & StdOut)
        Log("Err: "& StdErr)
    Else
        Log("Error: " & LastException)
    End If

I've searched the forum and the internet at large to try and find a solution but I'm not finding anything that helps with my situation. I've downloaded several different versions of libc++_shared.so for arm64 and also ripped some from the /date/app directory, but either I'm not adding them to my B4A project correctly, or I'm missing something else entirely.

Any help with this issue would be very much appreciated! Please let me know if I missed any info that should be included with my post.
 

Tyler

Member
Licensed User
Longtime User
Hi Erel! Glad to see you're still around after the years I've been away. I appreciate all the help you've provided me over the years despite my beginner-level questions, and thanks for chiming in once again!

I've written the following .class: file


Code:
public class LlamaWrapper {
    static {
        System.loadLibrary("c++_shared");
    }

    public native String runLlama(String[] args);

}

I've invoked javac and jar to create a .jar file containing this class and added it to my B4A libraries directory, however it doesn't show up in the libraries tab of my IDE. Sorry if this is a stupid question. I know next to nothing about Java in this context and am just using random examples to piece together the wrapper.


Thanks again!
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
You need an xml for the wrapper to show in the libraries tab.

something like LlamaWrapper.xml (same name as the jar file)
B4X:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<root>
    <doclet-version-NOT-library-version>2.00</doclet-version-NOT-library-version>
    <class>
        <name>LlamaWrapper</name>
        <shortname>LlamaWrapper</shortname>
        <method>
            <name>runLlama</name>
            <comment/>
            <returntype>java.lang.String</returntype>
            <parameter>
                <name>args</name>
                <type>java.lang.String[]</type>
            </parameter>
        </method>
    </class>
    <version>1.0</version>
    <author>Tyler</author>
</root>
 
Last edited:
Upvote 0
Top