fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
4.23k stars 291 forks source link

[Bug] Issue with passing arguments from rust to flutter? #1431

Closed kljohnsonn closed 9 months ago

kljohnsonn commented 10 months ago

Describe the bug

When trying to pass an argument like (url: String) i seem to encounter an error on the flutter side of my code telling me that my .so, .dll or .dylib has no symbol: Screenshot from 2023-12-06 19-47-12

The rust code i used to generate this was:

use std::ffi::{CStr, CString};

use reqwest;
use tokio;

pub fn greeting_from_rust(url: String) -> String {
    match reqwest::blocking::get(url) {
        Ok(resp) => match resp.text() {
            Ok(text) => text,
            Err(_) => "Error occurred while reading the response text.".to_string(),
        },
        Err(_) => "Error occurred while making the request.".to_string(),
    }
}

I have no clue what the issue is, im very new so im not sure how i am suppose to pass arguments.

Codegen logs with RUST_LOG=debug environment variable

mox@Mox-World:~/Projects/flutter/synapse$ flutter_rust_bridge_codegen --rust-input native/src/api.rs                             --dart-output lib/bridge_generated.dart --skip-deps-check --verbose
2023/12/07 18:49:52 [DEBUG] configs=[Opts { rust_input_path: "/home/mox/Projects/flutter/synapse/native/src/api.rs", dart_output_path: "/home/mox/Projects/flutter/synapse/lib/bridge_generated.dart", dart_decl_output_path: None, c_output_path: ["/tmp/.tmpwVfU1Y.h"], rust_crate_dir: "/home/mox/Projects/flutter/synapse/native", rust_output_path: "/home/mox/Projects/flutter/synapse/native/src/bridge_generated.rs", class_name: "Native", dart_format_line_length: 80, dart_enums_style: false, skip_add_mod_to_lib: false, llvm_path: ["/opt/homebrew/opt/llvm", "/usr/local/opt/llvm", "/usr/lib/llvm-9", "/usr/lib/llvm-10", "/usr/lib/llvm-11", "/usr/lib/llvm-12", "/usr/lib/llvm-13", "/usr/lib/llvm-14", "/usr/lib/", "/usr/lib64/", "C:/Program Files/llvm", "C:/msys64/mingw64"], llvm_compiler_opts: "", manifest_path: "/home/mox/Projects/flutter/synapse/native/Cargo.toml", dart_root: Some("/home/mox/Projects/flutter/synapse"), build_runner: true, block_index: BlockIndex(0), skip_deps_check: true, wasm_enabled: false, inline_rust: false, bridge_in_method: true, extra_headers: "", dart3: true, keep_going: false }]
2023/12/07 18:49:52 [DEBUG] Trying to parse "/home/mox/Projects/flutter/synapse/native/src/bridge_generated.rs"
2023/12/07 18:49:52 [WARN] Skipping unresolvable module io (tried /home/mox/Projects/flutter/synapse/native/src/io.rs, /home/mox/Projects/flutter/synapse/native/src/io/mod.rs, /home/mox/Projects/flutter/synapse/native/src/bridge_generated/io.rs, /home/mox/Projects/flutter/synapse/native/src/bridge_generated/io/mod.rs, )
2023/12/07 18:49:52 [DEBUG] Trying to parse "/home/mox/Projects/flutter/synapse/native/src/api.rs"
2023/12/07 18:49:52 [DEBUG] parse_function function name: Ident(greeting_from_rust)
2023/12/07 18:49:52 [INFO] Phase: Validate config(s)
2023/12/07 18:49:52 [INFO] Picked config: Opts { rust_input_path: "/home/mox/Projects/flutter/synapse/native/src/api.rs", dart_output_path: "/home/mox/Projects/flutter/synapse/lib/bridge_generated.dart", dart_decl_output_path: None, c_output_path: ["/tmp/.tmpwVfU1Y.h"], rust_crate_dir: "/home/mox/Projects/flutter/synapse/native", rust_output_path: "/home/mox/Projects/flutter/synapse/native/src/bridge_generated.rs", class_name: "Native", dart_format_line_length: 80, dart_enums_style: false, skip_add_mod_to_lib: false, llvm_path: ["/opt/homebrew/opt/llvm", "/usr/local/opt/llvm", "/usr/lib/llvm-9", "/usr/lib/llvm-10", "/usr/lib/llvm-11", "/usr/lib/llvm-12", "/usr/lib/llvm-13", "/usr/lib/llvm-14", "/usr/lib/", "/usr/lib64/", "C:/Program Files/llvm", "C:/msys64/mingw64"], llvm_compiler_opts: "", manifest_path: "/home/mox/Projects/flutter/synapse/native/Cargo.toml", dart_root: Some("/home/mox/Projects/flutter/synapse"), build_runner: true, block_index: BlockIndex(0), skip_deps_check: true, wasm_enabled: false, inline_rust: false, bridge_in_method: true, extra_headers: "", dart3: true, keep_going: false }
2023/12/07 18:49:52 [INFO] Phase: Parse source code to AST, then to IR
2023/12/07 18:49:53 [DEBUG] Trying to parse "/home/mox/Projects/flutter/synapse/native/src/bridge_generated.rs"
2023/12/07 18:49:53 [WARN] Skipping unresolvable module io (tried /home/mox/Projects/flutter/synapse/native/src/io.rs, /home/mox/Projects/flutter/synapse/native/src/io/mod.rs, /home/mox/Projects/flutter/synapse/native/src/bridge_generated/io.rs, /home/mox/Projects/flutter/synapse/native/src/bridge_generated/io/mod.rs, )
2023/12/07 18:49:53 [DEBUG] Trying to parse "/home/mox/Projects/flutter/synapse/native/src/api.rs"
2023/12/07 18:49:53 [DEBUG] parse_function function name: Ident(greeting_from_rust)
2023/12/07 18:49:53 [INFO] Phase: Transform IR
2023/12/07 18:49:53 [INFO] Phase: Generate Rust code
2023/12/07 18:49:53 [DEBUG] execute format_rust path=["/home/mox/Projects/flutter/synapse/native/src/bridge_generated.rs"]
2023/12/07 18:49:53 [DEBUG] execute command: bin=rustfmt args="/home/mox/Projects/flutter/synapse/native/src/bridge_generated.rs" current_dir=None cmd="rustfmt" "/home/mox/Projects/flutter/synapse/native/src/bridge_generated.rs"
2023/12/07 18:49:53 [DEBUG] command="rustfmt" "/home/mox/Projects/flutter/synapse/native/src/bridge_generated.rs" stdout= stderr=
2023/12/07 18:49:53 [INFO] Phase: Generate Dart code
2023/12/07 18:49:53 [DEBUG] Guessing toolchain the runner is run into
2023/12/07 18:49:53 [DEBUG] execute command: bin=sh args="-c \"flutter\" \"--version\"" current_dir=None cmd="sh" "-c" "\"flutter\" \"--version\""
Flutter 3.16.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 9e1c857886 (7 days ago) • 2023-11-30 11:51:18 -0600
Engine • revision cf7a9d0800
Tools • Dart 3.2.2 • DevTools 2.28.3
2023/12/07 18:49:53 [DEBUG] command="sh" "-c" "\"flutter\" \"--version\"" stdout= stderr=
2023/12/07 18:49:53 [INFO] Phase: Generating Dart bindings for Rust
2023/12/07 18:49:53 [DEBUG] execute cbindgen rust_crate_dir=/home/mox/Projects/flutter/synapse/native c_output_path=/tmp/.tmpcMjyuQ.h
2023/12/07 18:49:53 [DEBUG] cbindgen config: Config {
    header: None,
    includes: [],
    sys_includes: [
        "stdbool.h",
        "stdint.h",
        "stdlib.h",
    ],
    after_includes: Some(
        "typedef struct _Dart_Handle* Dart_Handle;",
    ),
    trailer: None,
    include_guard: None,
    pragma_once: false,
    no_includes: true,
    autogen_warning: None,
    include_version: false,
    namespace: None,
    namespaces: None,
    using_namespaces: None,
    braces: SameLine,
    line_length: 100,
    tab_width: 2,
    line_endings: LF,
    language: C,
    cpp_compat: false,
    style: Both,
    sort_by: None,
    usize_is_size_t: false,
    parse: ParseConfig {
        parse_deps: false,
        include: None,
        exclude: [],
        expand: ParseExpandConfig {
            crates: [],
            all_features: false,
            default_features: true,
            features: None,
            profile: Debug,
        },
        clean: false,
        extra_bindings: [],
    },
    export: ExportConfig {
        include: [],
        exclude: [],
        rename: {},
        pre_body: {},
        body: {},
        prefix: None,
        item_types: [],
        renaming_overrides_prefixing: false,
        mangle: MangleConfig {
            rename_types: None,
            remove_underscores: false,
        },
    },
    macro_expansion: MacroExpansionConfig {
        bitflags: false,
    },
    layout: LayoutConfig {
        packed: None,
        aligned_n: None,
    },
    function: FunctionConfig {
        prefix: None,
        postfix: None,
        must_use: None,
        args: Auto,
        rename_args: None,
        swift_name_macro: None,
        sort_by: None,
        no_return: None,
    },
    structure: StructConfig {
        rename_fields: None,
        derive_constructor: false,
        derive_eq: false,
        derive_neq: false,
        derive_lt: false,
        derive_lte: false,
        derive_gt: false,
        derive_gte: false,
        derive_ostream: false,
        associated_constants_in_body: false,
        must_use: None,
    },
    enumeration: EnumConfig {
        rename_variants: None,
        rename_variant_name_fields: SnakeCase,
        add_sentinel: false,
        prefix_with_name: false,
        derive_helper_methods: false,
        derive_const_casts: false,
        derive_mut_casts: false,
        cast_assert_name: None,
        must_use: None,
        derive_tagged_enum_destructor: false,
        derive_tagged_enum_copy_constructor: false,
        derive_tagged_enum_copy_assignment: false,
        derive_ostream: false,
        enum_class: true,
        private_default_tagged_enum_constructor: false,
    },
    constant: ConstantConfig {
        allow_static_const: true,
        allow_constexpr: true,
        sort_by: None,
    },
    defines: {},
    documentation: true,
    documentation_style: Auto,
    documentation_length: Full,
    pointer: PtrConfig {
        non_null_attribute: None,
    },
    only_target_dependencies: false,
    cython: CythonConfig {
        header: None,
        cimports: {},
    },
}
2023/12/07 18:49:53 [DEBUG] Parsing crate native
2023/12/07 18:49:53 [INFO] Take native::DartPort.
2023/12/07 18:49:53 [INFO] Take native::DartPostCObjectFnType.
2023/12/07 18:49:53 [INFO] Take native::store_dart_post_cobject.
2023/12/07 18:49:53 [INFO] Take native::get_dart_object.
2023/12/07 18:49:53 [INFO] Take native::drop_dart_object.
2023/12/07 18:49:53 [INFO] Take native::new_dart_opaque.
2023/12/07 18:49:53 [INFO] Take native::init_frb_dart_api_dl.
2023/12/07 18:49:53 [INFO] Take native::DartCObject - opaque (Struct is not marked #[repr(C)] or #[repr(transparent)].).
2023/12/07 18:49:53 [INFO] Take native::WireSyncReturn.
2023/12/07 18:49:53 [INFO] Take native::wire_greeting_from_rust.
2023/12/07 18:49:53 [INFO] Take native::new_uint_8_list_0.
2023/12/07 18:49:53 [INFO] Take native::wire_uint_8_list.
2023/12/07 18:49:53 [INFO] Take native::free_WireSyncReturn.
2023/12/07 18:49:53 [WARN] Can't find Dart_Handle. This usually means that this type was incompatible or not found.
2023/12/07 18:49:53 [WARN] Can't find Dart_Handle. This usually means that this type was incompatible or not found.
2023/12/07 18:49:53 [WARN] Missing `[defines]` entry for `target_family = "wasm"` in cbindgen config.
2023/12/07 18:49:53 [WARN] Missing `[defines]` entry for `target_family = "wasm"` in cbindgen config.
2023/12/07 18:49:53 [WARN] Missing `[defines]` entry for `target_family = "wasm"` in cbindgen config.
2023/12/07 18:49:53 [WARN] Missing `[defines]` entry for `target_family = "wasm"` in cbindgen config.
2023/12/07 18:49:53 [DEBUG] execute ffigen c_path=/tmp/.tmpcMjyuQ.h dart_path=/tmp/.tmpktDSyg llvm_path=["/opt/homebrew/opt/llvm", "/usr/local/opt/llvm", "/usr/lib/llvm-9", "/usr/lib/llvm-10", "/usr/lib/llvm-11", "/usr/lib/llvm-12", "/usr/lib/llvm-13", "/usr/lib/llvm-14", "/usr/lib/", "/usr/lib64/", "C:/Program Files/llvm", "C:/msys64/mingw64"]
2023/12/07 18:49:53 [DEBUG] ffigen config: 
        output: '/tmp/.tmpktDSyg'
        name: 'NativeWire'
        description: 'generated by flutter_rust_bridge'
        headers:
          entry-points:
            - '/tmp/.tmpcMjyuQ.h'
          include-directives:
            - '/tmp/.tmpcMjyuQ.h'
        comments: false
        preamble: |
          // ignore_for_file: camel_case_types, non_constant_identifier_names, avoid_positional_boolean_parameters, annotate_overrides, constant_identifier_names

        llvm-path:
           - '/opt/homebrew/opt/llvm'
           - '/usr/local/opt/llvm'
           - '/usr/lib/llvm-9'
           - '/usr/lib/llvm-10'
           - '/usr/lib/llvm-11'
           - '/usr/lib/llvm-12'
           - '/usr/lib/llvm-13'
           - '/usr/lib/llvm-14'
           - '/usr/lib/'
           - '/usr/lib64/'
           - 'C:/Program Files/llvm'
           - 'C:/msys64/mingw64'

2023/12/07 18:49:53 [DEBUG] ffigen config_file: NamedTempFile("/tmp/.tmpSQrK6X")
2023/12/07 18:49:53 [DEBUG] Guessing toolchain the runner is run into
2023/12/07 18:49:53 [DEBUG] execute command: bin=sh args="-c \"flutter\" \"pub\" \"run\" \"ffigen\" \"--config\" \"/tmp/.tmpSQrK6X\"" current_dir=Some("/home/mox/Projects/flutter/synapse") cmd=cd "/home/mox/Projects/flutter/synapse" && "sh" "-c" "\"flutter\" \"pub\" \"run\" \"ffigen\" \"--config\" \"/tmp/.tmpSQrK6X\""
Deprecated. Use `dart run` instead.
Running in Directory: '/home/mox/Projects/flutter/synapse'
Input Headers: [/tmp/.tmpcMjyuQ.h]
[WARNING]: No definition found for declaration - (Cursor) spelling: _Dart_Handle, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct _Dart_Handle, usr: c:@S@_Dart_Handle
[WARNING]: No definition found for declaration - (Cursor) spelling: _Dart_Handle, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct _Dart_Handle, usr: c:@S@_Dart_Handle
[WARNING]: No definition found for declaration - (Cursor) spelling: DartCObject, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct DartCObject, usr: c:@S@DartCObject
[WARNING]: No definition found for declaration - (Cursor) spelling: DartCObject, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct DartCObject, usr: c:@S@DartCObject
[WARNING]: No definition found for declaration - (Cursor) spelling: _Dart_Handle, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct _Dart_Handle, usr: c:@S@_Dart_Handle
[WARNING]: No definition found for declaration - (Cursor) spelling: _Dart_Handle, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct _Dart_Handle, usr: c:@S@_Dart_Handle
[WARNING]: No definition found for declaration - (Cursor) spelling: _Dart_Handle, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct _Dart_Handle, usr: c:@S@_Dart_Handle
[WARNING]: No definition found for declaration - (Cursor) spelling: _Dart_Handle, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct _Dart_Handle, usr: c:@S@_Dart_Handle
[WARNING]: No definition found for declaration - (Cursor) spelling: DartCObject, kind: 2, kindSpelling: StructDecl, type: 105, typeSpelling: struct DartCObject, usr: c:@S@DartCObject
[WARNING]: Generated declaration '_Dart_Handle' start's with '_' and therefore will be private.
Finished, Bindings generated in /tmp/.tmpktDSyg
2023/12/07 18:49:55 [DEBUG] command=cd "/home/mox/Projects/flutter/synapse" && "sh" "-c" "\"flutter\" \"pub\" \"run\" \"ffigen\" \"--config\" \"/tmp/.tmpSQrK6X\"" stdout= stderr=
the path is "/tmp/.tmpwVfU1Y.h"
2023/12/07 18:49:55 [DEBUG] distinct_input_types=[Delegate(String), Primitive(U8), PrimitiveList(IrTypePrimitiveList { primitive: U8 })]
2023/12/07 18:49:55 [DEBUG] distinct_output_types=[Delegate(String), Primitive(U8), PrimitiveList(IrTypePrimitiveList { primitive: U8 })]
2023/12/07 18:49:55 [INFO] Phase: Running build_runner
2023/12/07 18:49:55 [INFO] Phase: Formatting Dart code
2023/12/07 18:49:55 [DEBUG] execute format_dart path=["/home/mox/Projects/flutter/synapse/lib/bridge_generated.dart"] line_length=80
2023/12/07 18:49:55 [DEBUG] execute command: bin=sh args="-c \"dart\" \"format\" \"--line-length\" \"80\" \"/home/mox/Projects/flutter/synapse/lib/bridge_generated.dart\"" current_dir=None cmd="sh" "-c" "\"dart\" \"format\" \"--line-length\" \"80\" \"/home/mox/Projects/flutter/synapse/lib/bridge_generated.dart\""
Formatted /home/mox/Projects/flutter/synapse/lib/bridge_generated.dart
Formatted 1 file (1 changed) in 0.31 seconds.
2023/12/07 18:49:56 [DEBUG] command="sh" "-c" "\"dart\" \"format\" \"--line-length\" \"80\" \"/home/mox/Projects/flutter/synapse/lib/bridge_generated.dart\"" stdout= stderr=
2023/12/07 18:49:56 [INFO] Success!
2023/12/07 18:49:56 [INFO] Now go and use it :)

To Reproduce

Just reuse my code in your .api.rs file and use the codegen

Expected behavior

No error should appear and my code should display a http response

Generated binding code

dart generated:

// AUTO GENERATED FILE, DO NOT EDIT.
// Generated by `flutter_rust_bridge`@ 1.80.1.
// ignore_for_file: non_constant_identifier_names, unused_element, duplicate_ignore, directives_ordering, curly_braces_in_flow_control_structures, unnecessary_lambdas, slash_for_doc_comments, prefer_const_literals_to_create_immutables, implicit_dynamic_list_literal, duplicate_import, unused_import, unnecessary_import, prefer_single_quotes, prefer_const_constructors, use_super_parameters, always_use_package_imports, annotate_overrides, invalid_use_of_protected_member, constant_identifier_names, invalid_use_of_internal_member, prefer_is_empty, unnecessary_const

import 'dart:convert';
import 'dart:async';
import 'package:meta/meta.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge.dart';
import 'package:uuid/uuid.dart';

import 'dart:ffi' as ffi;

abstract class Native {
  Future<String> greetingFromRust({required String url, dynamic hint});

  FlutterRustBridgeTaskConstMeta get kGreetingFromRustConstMeta;
}

class NativeImpl implements Native {
  final NativePlatform _platform;
  factory NativeImpl(ExternalLibrary dylib) =>
      NativeImpl.raw(NativePlatform(dylib));

  /// Only valid on web/WASM platforms.
  factory NativeImpl.wasm(FutureOr<WasmModule> module) =>
      NativeImpl(module as ExternalLibrary);
  NativeImpl.raw(this._platform);
  Future<String> greetingFromRust({required String url, dynamic hint}) {
    var arg0 = _platform.api2wire_String(url);
    return _platform.executeNormal(FlutterRustBridgeTask(
      callFfi: (port_) => _platform.inner.wire_greeting_from_rust(port_, arg0),
      parseSuccessData: _wire2api_String,
      constMeta: kGreetingFromRustConstMeta,
      argValues: [url],
      hint: hint,
    ));
  }

  FlutterRustBridgeTaskConstMeta get kGreetingFromRustConstMeta =>
      const FlutterRustBridgeTaskConstMeta(
        debugName: "greeting_from_rust",
        argNames: ["url"],
      );

  void dispose() {
    _platform.dispose();
  }
// Section: wire2api

  String _wire2api_String(dynamic raw) {
    return raw as String;
  }

  int _wire2api_u8(dynamic raw) {
    return raw as int;
  }

  Uint8List _wire2api_uint_8_list(dynamic raw) {
    return raw as Uint8List;
  }
}

// Section: api2wire

@protected
int api2wire_u8(int raw) {
  return raw;
}

// Section: finalizer

class NativePlatform extends FlutterRustBridgeBase<NativeWire> {
  NativePlatform(ffi.DynamicLibrary dylib) : super(NativeWire(dylib));

// Section: api2wire

  @protected
  ffi.Pointer<wire_uint_8_list> api2wire_String(String raw) {
    return api2wire_uint_8_list(utf8.encoder.convert(raw));
  }

  @protected
  ffi.Pointer<wire_uint_8_list> api2wire_uint_8_list(Uint8List raw) {
    final ans = inner.new_uint_8_list_0(raw.length);
    ans.ref.ptr.asTypedList(raw.length).setAll(0, raw);
    return ans;
  }
// Section: finalizer

// Section: api_fill_to_wire
}

// ignore_for_file: camel_case_types, non_constant_identifier_names, avoid_positional_boolean_parameters, annotate_overrides, constant_identifier_names

// AUTO GENERATED FILE, DO NOT EDIT.
//
// Generated by `package:ffigen`.
// ignore_for_file: type=lint

/// generated by flutter_rust_bridge
class NativeWire implements FlutterRustBridgeWireBase {
  @internal
  late final dartApi = DartApiDl(init_frb_dart_api_dl);

  /// Holds the symbol lookup function.
  final ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
      _lookup;

  /// The symbols are looked up in [dynamicLibrary].
  NativeWire(ffi.DynamicLibrary dynamicLibrary)
      : _lookup = dynamicLibrary.lookup;

  /// The symbols are looked up with [lookup].
  NativeWire.fromLookup(
      ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
          lookup)
      : _lookup = lookup;

  void store_dart_post_cobject(
    DartPostCObjectFnType ptr,
  ) {
    return _store_dart_post_cobject(
      ptr,
    );
  }

  late final _store_dart_post_cobjectPtr =
      _lookup<ffi.NativeFunction<ffi.Void Function(DartPostCObjectFnType)>>(
          'store_dart_post_cobject');
  late final _store_dart_post_cobject = _store_dart_post_cobjectPtr
      .asFunction<void Function(DartPostCObjectFnType)>();

  Object get_dart_object(
    int ptr,
  ) {
    return _get_dart_object(
      ptr,
    );
  }

  late final _get_dart_objectPtr =
      _lookup<ffi.NativeFunction<ffi.Handle Function(ffi.UintPtr)>>(
          'get_dart_object');
  late final _get_dart_object =
      _get_dart_objectPtr.asFunction<Object Function(int)>();

  void drop_dart_object(
    int ptr,
  ) {
    return _drop_dart_object(
      ptr,
    );
  }

  late final _drop_dart_objectPtr =
      _lookup<ffi.NativeFunction<ffi.Void Function(ffi.UintPtr)>>(
          'drop_dart_object');
  late final _drop_dart_object =
      _drop_dart_objectPtr.asFunction<void Function(int)>();

  int new_dart_opaque(
    Object handle,
  ) {
    return _new_dart_opaque(
      handle,
    );
  }

  late final _new_dart_opaquePtr =
      _lookup<ffi.NativeFunction<ffi.UintPtr Function(ffi.Handle)>>(
          'new_dart_opaque');
  late final _new_dart_opaque =
      _new_dart_opaquePtr.asFunction<int Function(Object)>();

  int init_frb_dart_api_dl(
    ffi.Pointer<ffi.Void> obj,
  ) {
    return _init_frb_dart_api_dl(
      obj,
    );
  }

  late final _init_frb_dart_api_dlPtr =
      _lookup<ffi.NativeFunction<ffi.IntPtr Function(ffi.Pointer<ffi.Void>)>>(
          'init_frb_dart_api_dl');
  late final _init_frb_dart_api_dl = _init_frb_dart_api_dlPtr
      .asFunction<int Function(ffi.Pointer<ffi.Void>)>();

  void wire_greeting_from_rust(
    int port_,
    ffi.Pointer<wire_uint_8_list> url,
  ) {
    return _wire_greeting_from_rust(
      port_,
      url,
    );
  }

  late final _wire_greeting_from_rustPtr = _lookup<
      ffi.NativeFunction<
          ffi.Void Function(ffi.Int64,
              ffi.Pointer<wire_uint_8_list>)>>('wire_greeting_from_rust');
  late final _wire_greeting_from_rust = _wire_greeting_from_rustPtr
      .asFunction<void Function(int, ffi.Pointer<wire_uint_8_list>)>();

  ffi.Pointer<wire_uint_8_list> new_uint_8_list_0(
    int len,
  ) {
    return _new_uint_8_list_0(
      len,
    );
  }

  late final _new_uint_8_list_0Ptr = _lookup<
          ffi
          .NativeFunction<ffi.Pointer<wire_uint_8_list> Function(ffi.Int32)>>(
      'new_uint_8_list_0');
  late final _new_uint_8_list_0 = _new_uint_8_list_0Ptr
      .asFunction<ffi.Pointer<wire_uint_8_list> Function(int)>();

  void free_WireSyncReturn(
    WireSyncReturn ptr,
  ) {
    return _free_WireSyncReturn(
      ptr,
    );
  }

  late final _free_WireSyncReturnPtr =
      _lookup<ffi.NativeFunction<ffi.Void Function(WireSyncReturn)>>(
          'free_WireSyncReturn');
  late final _free_WireSyncReturn =
      _free_WireSyncReturnPtr.asFunction<void Function(WireSyncReturn)>();
}

final class _Dart_Handle extends ffi.Opaque {}

final class wire_uint_8_list extends ffi.Struct {
  external ffi.Pointer<ffi.Uint8> ptr;

  @ffi.Int32()
  external int len;
}

typedef DartPostCObjectFnType
    = ffi.Pointer<ffi.NativeFunction<DartPostCObjectFnTypeFunction>>;
typedef DartPostCObjectFnTypeFunction = ffi.Bool Function(
    DartPort port_id, ffi.Pointer<ffi.Void> message);
typedef DartDartPostCObjectFnTypeFunction = bool Function(
    DartDartPort port_id, ffi.Pointer<ffi.Void> message);
typedef DartPort = ffi.Int64;
typedef DartDartPort = int;

rust generated:
```rust
use super::*;
// Section: wire functions

#[no_mangle]
pub extern "C" fn wire_greeting_from_rust(port_: i64, url: *mut wire_uint_8_list) {
    wire_greeting_from_rust_impl(port_, url)
}

// Section: allocate functions

#[no_mangle]
pub extern "C" fn new_uint_8_list_0(len: i32) -> *mut wire_uint_8_list {
    let ans = wire_uint_8_list {
        ptr: support::new_leak_vec_ptr(Default::default(), len),
        len,
    };
    support::new_leak_box_ptr(ans)
}

// Section: related functions

// Section: impl Wire2Api

impl Wire2Api<String> for *mut wire_uint_8_list {
    fn wire2api(self) -> String {
        let vec: Vec<u8> = self.wire2api();
        String::from_utf8_lossy(&vec).into_owned()
    }
}

impl Wire2Api<Vec<u8>> for *mut wire_uint_8_list {
    fn wire2api(self) -> Vec<u8> {
        unsafe {
            let wrap = support::box_from_leak_ptr(self);
            support::vec_from_leak_ptr(wrap.ptr, wrap.len)
        }
    }
}
// Section: wire structs

#[repr(C)]
#[derive(Clone)]
pub struct wire_uint_8_list {
    ptr: *mut u8,
    len: i32,
}

// Section: impl NewWithNullPtr

pub trait NewWithNullPtr {
    fn new_with_null_ptr() -> Self;
}

impl<T> NewWithNullPtr for *mut T {
    fn new_with_null_ptr() -> Self {
        std::ptr::null_mut()
    }
}

// Section: sync execution mode utility

#[no_mangle]
pub extern "C" fn free_WireSyncReturn(ptr: support::WireSyncReturn) {
    unsafe {
        let _ = support::box_from_leak_ptr(ptr);
    };
}

### OS

Linux Mint

### Version of `flutter_rust_bridge_codegen`

1.80.1- Since any other version throws a lot of erros

### Flutter info

```shell
mox@Mox-World:~/Projects/flutter/synapse$ flutter doctor -v
[✓] Flutter (Channel stable, 3.16.2, on Linux Mint 21.2 6.5.0-1008-oem, locale en_US.UTF-8)
    • Flutter version 3.16.2 on channel stable at /home/mox/Downloads/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 9e1c857886 (7 days ago), 2023-11-30 11:51:18 -0600
    • Engine revision cf7a9d0800
    • Dart version 3.2.2
    • DevTools version 2.28.3

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Linux toolchain - develop for Linux desktop
    • Ubuntu clang version 14.0.0-1ubuntu1.1
    • cmake version 3.22.1
    • ninja version 1.10.1
    • pkg-config version 0.29.2

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).

[✓] VS Code (version 1.84.2)
    • VS Code at /usr/share/code
    • Flutter extension version 3.78.0

[✓] Connected device (1 available)
    • Linux (desktop) • linux • linux-x64 • Linux Mint 21.2 6.5.0-1008-oem

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 3 categories.

Version of clang++

Ubuntu clang version 14.0.0-1ubuntu1.1 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin

Version of ffigen

9.0.0

Additional context

No response

fzyzcjy commented 10 months ago

Firstly, maybe ensure your generated binary (.so/.dylib/whatever) is up-to-date.

Secondly, v2 will handle all these compilation for you :)

fzyzcjy commented 9 months ago

Hi, v2 has been released, and feel free to create issues if the error still exists (I guess it will be fixed since v2 handles the symbols etc by default)!

github-actions[bot] commented 9 months ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.