Skip to content

Linux dart native "Couldn't resolve native function 'llama_backend_init" #3

@guyluz11

Description

@guyluz11

I am running the example project on Linux dart native.

Flutter version

 flutter --version
Flutter 3.33.0-1.0.pre.416 • channel master • https://github.com/flutter/flutter.git
Framework • revision 2eec076321 (13 hours ago) • 2025-06-06 19:40:24 -0400
Engine • revision 2eec076321 (13 hours ago) • 2025-06-06 19:40:24 -0400
ToolsDart 3.9.0 (build 3.9.0-210.0.dev) • DevTools 2.48.0-dev.0

I have just followed the instructions on the readme file

Trying examples

git clone https://github.com/lindeer/llama-cpp.git
cd llama-cpp
git submodule init --recursive
dart pub get

Just run in console:

dart --enable-experiment=native-assets run example/main.dart "/path/to/your/LLM.gguf" "your prompt"

And I got this error

$ dart --enable-experiment=native-assets run example/main.dart "/home/guyc/Downloads/Nous-Hermes-2-Mistral-7B-DPO.Q5_K_M.gguf"  "your text line1
your text line2"
seed = 1749300217
llama backend init
Unhandled exception:
Invalid argument(s): Couldn't resolve native function 'llama_backend_init' in 'package:llama_cpp/src/lib_llama_cpp.dart' : No asset with id 'package:llama_cpp/src/lib_llama_cpp.dart' found. Available native assets: . Attempted to fallback to process lookup. /home/guyc/programs/flutter/bin/cache/dart-sdk/bin/dart: undefined symbol: llama_backend_init.

#0      Native._ffi_resolver.#ffiClosure0 (dart:ffi-patch/ffi_patch.dart)
#1      Native._ffi_resolver_function (dart:ffi-patch/ffi_patch.dart:1939:20)
#2      llama_backend_init (package:llama_cpp/src/lib_llama_cpp.dart)
#3      loadModel (package:llama_cpp/src/common.dart:116:13)
#4      new NativeLLama (package:llama_cpp/src/native_llama.dart:46:28)
#5      LlamaCpp._llamaIsolate (package:llama_cpp/llama_cpp.dart:175:19)
#6      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:317:17)
#7      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:193:12)

Or for embedding

$ dart --enable-experiment=native-assets run example/embedding.dart "/home/guyc/Downloads/smollm2-360m-instruct-q8_0.gguf"  "your text line1
your text line2"
seed = 1234
llama backend init
Unhandled exception:
Invalid argument(s): Couldn't resolve native function 'llama_backend_init' in 'package:llama_cpp/src/lib_llama_cpp.dart' : No asset with id 'package:llama_cpp/src/lib_llama_cpp.dart' found. Available native assets: . Attempted to fallback to process lookup. /home/guyc/programs/flutter/bin/cache/dart-sdk/bin/dart: undefined symbol: llama_backend_init.

#0      Native._ffi_resolver.#ffiClosure0 (dart:ffi-patch/ffi_patch.dart)
#1      Native._ffi_resolver_function (dart:ffi-patch/ffi_patch.dart:1939:20)
#2      llama_backend_init (package:llama_cpp/src/lib_llama_cpp.dart)
#3      loadModel (package:llama_cpp/src/common.dart:116:13)
#4      main (file:///home/guyc/Documents/git/llama-cpp/example/embedding.dart:20:26)
#5      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:312:33)
#6      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:193:12)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions