sdk icon indicating copy to clipboard operation
sdk copied to clipboard

ffi.DynamicLibrary. Error in open loading vs2012 compiled DLL

Open xz-zone opened this issue 2 years ago • 3 comments

I have sought various ways and tried various ways. There is still this problem. The following is a screenshot of my system parameter information and error reporting。 Operating system: Windows Dart environment: dart SDK version: 2.17.5 (stable) (Tue Jun 21 11:05:10 2022+0200) on "windows_x64" Compiling DLL environment: vs2012 Error reporting log: Unhandled exception: Invalid argument(s): Failed to load dynamic library './full_all/Dll164.dll': error code 126 #0 _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:12:43) https://github.com/flutter/flutter/pull/1 new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:23:12) https://github.com/flutter/flutter/pull/2 main (file:///c:/Users/Administrator/Desktop/dart/newuser.dart:27:40) https://github.com/flutter/flutter/pull/3 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:295:32) https://github.com/flutter/flutter/issues/4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)

c code `#include <windows.h>

int add(int a, int b){ return a + b; }

void showBox(){ MessageBox(NULL,"Hello Dart","Title",MB_OK); }`

dart code `iimport 'dart:ffi' as ffi; import 'dart:io' show Platform, Directory; import 'package:path/path.dart' as path;

void main(List<String> args) { final _kernel32 = ffi.DynamicLibrary.open( path.join(Directory.current.path, 'full_all', 'Dll164.dll')); print(_kernel32); } `

Screenshot of operation image

The same problem, the following figure is the result I detected with sigcheck

image

xz-zone avatar Jul 29 '22 05:07 xz-zone

/cc @dcharkes

mraleph avatar Aug 01 '22 09:08 mraleph

@xz-zone, error code 126 on Windows often is missing dependencies. See https://stackoverflow.com/a/14362289/8136619.

In order for me to troubleshoot your problem, please provide a repository with a minimal reproduction. Please include the Dart and C source code and the specific reproduction steps (especially how you build the C sources to a dynamic library). Also, please specify the specific versions of all tools used. (What version of vs2012?)

Do you succeed with using other compilers? For example with clang?

dcharkes avatar Aug 01 '22 10:08 dcharkes

@xz-zone, error code 126 on Windows often is missing dependencies. See https://stackoverflow.com/a/14362289/8136619.

In order for me to troubleshoot your problem, please provide a repository with a minimal reproduction. Please include the Dart and C source code and the specific reproduction steps (especially how you build the C sources to a dynamic library). Also, please specify the specific versions of all tools used. (What version of vs2012?)

Do you succeed with using other compilers? For example with clang?

I use the tool visual studio 2012

xz-zone avatar Aug 02 '22 07:08 xz-zone

@xz-zone did you resolve this issue? If so, how?

sneurlax avatar Nov 02 '22 13:11 sneurlax

pendencies. See https:/

Use visual studio 2012 and change the compilation mode to x64 bit

xz-zone avatar Nov 03 '22 01:11 xz-zone