Open brizaldi opened 1 year ago
Not just the .DLL
you're trying to load (using DynamicLibrary.open
) needs to exist, but any of the .DLL
files on which that .DLL
itself depends upon need to be reachable. Safest approach is to place all of them in the executable's directory.
I have checked some of the dependencies required by librdkafka.dll using this tool:
And I have put all of them into one folder along with librdkafka.dll. However, I am still getting the same error.
Similar issue:
Can you check whether the file exists with File.existsSync()
just to be sure the path-handling (separators etc) is correct?
I have checked some of the dependencies required by librdkafka.dll using this tool:
- KERNEL32.dll
- libcrypto-3-x64.dll
- libcurl.dll
- libssl-3-x64.dll
- zlib1.dll
- zstd.dll
- Secur32.dll
- WS2_32.dll
- CRYPT32.dll
And I have put all of them into one folder along with librdkafka.dll. However, I am still getting the same error.
And this would indeed my second suggestion.
Did you get it to work?
Can you check whether the file exists with
File.existsSync()
just to be sure the path-handling (separators etc) is correct?
The path is correct since File.existsSync()
returns true
Did you get it to work?
No, currently still stuck at loading the librdkafka library
You could try running dart.exe
with the right arguments in the visual studio debugger.
I can load other DLLs fine, for example like the hello.dll from the official example or the libcurl.dll from above. However, when I try to load this librdkafka.dll, an error occurs.
I'm having the same issue when compiling OpenCV
.
I can use WSL
to compile OpenCV to a .so
library, run dart run ffigen
to generate bindings and everything works in Dart. This, however, isn't ideal since WSL cannot access USB devices or webcams, which means I can't actually stream any video.
So I tried the process again on Windows. I used Visual Studio to generate a whole bunch of .dll
s with cmake .
in opencv\build\bin\Debug
, but Dart gives an error 126 when I load one. This error does not occur when building other, simpler C projects on Windows.
I'm happy to provide more details if needed.
EDIT: I seemed to have fixed it by adding the folder with all the DLL's to my system path. I thought that wouldn't be needed since they were in the same folder together but since my terminal isn't in that folder, it didn't matter.
I'm having the same issue when compiling
OpenCV
.I can use
WSL
to compile OpenCV to a.so
library, rundart run ffigen
to generate bindings and everything works in Dart. This, however, isn't ideal since WSL cannot access USB devices or webcams, which means I can't actually stream any video.So I tried the process again on Windows. I used Visual Studio to generate a whole bunch of
.dll
s withcmake .
inopencv\build\bin\Debug
, but Dart gives an error 126 when I load one. This error does not occur when building other, simpler C projects on Windows.I'm happy to provide more details if needed.
EDIT: I seemed to have fixed it by adding the folder with all the DLL's to my system path. I thought that wouldn't be needed since they were in the same folder together but since my terminal isn't in that folder, it didn't matter.
You had to add the folder which contain all dll's to system environment variables path??
I believe so.
In Linux, there is an environment variable called LD_LIBRARY_PATH
, which allows Linux to find .so
files when they are linked at runtime. It's like the normal PATH
variable on Windows, but exclusively for linked libraries.
Windows doesn't have another path variable like this (or at least, I didn't try one), so adding it to the system/user PATH
is good enough. Of course, if your terminal is already in this folder, you don't need to add it, but in some cases you do:
myProject/
- bin/
- project.exe
- library.dll
If your terminal is in myProject
, and you run bin\project.exe
, then library.dll
is not in your PATH
or the current working directory (that would be myProject
), so you need to add it to your PATH
.
The way I get around it is by assuming my terminal is in myProject
and making the code reference the .dll
from there, so DynamicLibrary.open("bin/library.dll")
. I also generate my .dll
s in the root folder sometimes, when that's more convenient.
Hi, I got an error like this when trying to use ffi to load the librdkafka library.
I obtained the librdkafka.dll file from NuGet. https://www.nuget.org/packages/librdkafka.redist/
and here's my code:
Dart SDK version: 2.19.3 OS: Windows 11 22H2 build 22621.1344