Skip to content

dart ffi: error code 126 #51659

@brizaldi

Description

@brizaldi

Hi, I got an error like this when trying to use ffi to load the librdkafka library.

Unhandled exception:
Invalid argument(s): Failed to load dynamic library 'C:\Projects\Dart\ffi_demo\library\librdkafka.dll': error code 126
#0      _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:11:43)
#1      new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:22:12)
#2      main (file:///C:/Projects/Dart/ffi_demo\/bin/main.dart:26:36)
#3      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
#4      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192:26)

I obtained the librdkafka.dll file from NuGet.
https://www.nuget.org/packages/librdkafka.redist/

and here's my code:

import 'dart:ffi' as ffi;
import 'dart:io' show Platform, Directory;

import 'package:path/path.dart' as path;

void main() {
  final libraryPath = path.join(Directory.current.path, 'library', 'librdkafka.dll');
  final dylib = ffi.DynamicLibrary.open(libraryPath);
}

Dart SDK version: 2.19.3
OS: Windows 11 22H2 build 22621.1344

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-ffi

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions