Skip to content

Commit 36d8862

Browse files
committed
Declare loadModelWithProgress in jllama.h to fix UnsatisfiedLinkError
PR #188 added loadModelWithProgress in Java (LlamaModel.java:380) and a matching JNIEXPORT definition in jllama.cpp (line 747), but forgot to add the forward declaration to the legacy hand-rolled jllama.h. The generated header net_ladenthin_llama_LlamaModel.h has it, but jllama.cpp only #includes jllama.h. Without the prior 'extern "C"' declaration in scope, the C++ compiler treats the function definition as a normal C++ function and produces a mangled symbol: _Z57Java_net_ladenthin_llama_LlamaModel_loadModelWithProgress... while the JVM looks up the unmangled name and throws UnsatisfiedLinkError: 'void net.ladenthin.llama.LlamaModel .loadModelWithProgress(java.lang.String[], net.ladenthin.llama.LoadProgressCallback)' at runtime. Adding the declaration to jllama.h restores C linkage. The plain loadModel symbol was unaffected because its declaration was already present. Verified locally with nm -D libjllama.so: before: _Z57Java_..._loadModelWithProgress... (mangled) after: Java_..._loadModelWithProgress (plain C) This unblocks LoadProgressCallbackTest on all platforms.
1 parent 353db74 commit 36d8862

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/main/cpp/jllama.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ JNIEXPORT jbyteArray JNICALL Java_net_ladenthin_llama_LlamaModel_decodeBytes(JNI
7070
*/
7171
JNIEXPORT void JNICALL Java_net_ladenthin_llama_LlamaModel_loadModel(JNIEnv *, jobject, jobjectArray);
7272

73+
/*
74+
* Class: net_ladenthin_llama_LlamaModel
75+
* Method: loadModelWithProgress
76+
* Signature: ([Ljava/lang/String;Lnet/ladenthin/llama/LoadProgressCallback;)V
77+
*/
78+
JNIEXPORT void JNICALL Java_net_ladenthin_llama_LlamaModel_loadModelWithProgress(JNIEnv *, jobject, jobjectArray, jobject);
79+
7380
/*
7481
* Class: net_ladenthin_llama_LlamaModel
7582
* Method: delete

0 commit comments

Comments
 (0)