Commit 36d8862
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
73 | 80 | | |
74 | 81 | | |
75 | 82 | | |
| |||
0 commit comments