Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Failed to load dynamic library 'libopencv_ffi.so' #9

Closed
guyluz11 opened this issue Oct 9, 2023 · 6 comments
Closed

Error Failed to load dynamic library 'libopencv_ffi.so' #9

guyluz11 opened this issue Oct 9, 2023 · 6 comments

Comments

@guyluz11
Copy link
Contributor

guyluz11 commented Oct 9, 2023

OS: Linux

/home/guyluz/Programs/flutter/bin/cache/dart-sdk/bin/dart --enable-asserts /home/guyluz/Documents/git/opencv_ffi/example/example.dart
Unhandled exception:
Invalid argument(s): Failed to load dynamic library 'libopencv_ffi.so': libopencv_ffi.so: cannot open shared object file: No such file or directory
#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      nativeLib (package:opencv_ffi/src/ffi.dart:21:49)
#3      nativeLib (package:opencv_ffi/src/ffi.dart)
#4      new Camera.fromName (package:opencv_ffi/src/camera.dart:28:31)
#5      main (file:///home/guyluz/Documents/git/opencv_ffi/example/example.dart:6:57)
#6      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:296:19)
#7      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)

Process finished with exit code 255
@Levi-Lesches
Copy link
Owner

As mentioned in #4, please add the full path of dist to your computer's LD_LIBRARY_PATH for Dart to find it.

@guyluz11
Copy link
Contributor Author

It should be part of the readme.

Thanks it worked

@Levi-Lesches
Copy link
Owner

It is:

Add the dist folder to your PATH. Restart your terminal/IDE and run your project as normal.

The script will output a command to add the dist folder to your LD_LIBRARY_PATH. You only need to run this command once, even if you modify and rebuild OpenCV, but you must run it again if you move the dist folder.

@SkytAsul
Copy link

SkytAsul commented Oct 31, 2024

I am getting this error after downloading the package using flutter pub add opencv_ffi. Is it expected behavior? Is it needed that I build the package myself?
EDIT: oops, didn't read the README enough.
I still have one question though: if I want to deploy my application, will it work normally or should the users also build OpenCV themselves?

@Levi-Lesches
Copy link
Owner

Currently, the plugin is lacking the ability to package itself, because Dart doesn't offer it.

In the future, the Native Assets feature will cover this automatically for both Dart and Flutter. Currently, this is possible to set this up in a somewhat hacky way for Flutter. opencv_camera is my attempt at that, but I don't believe it is fully ready. If you're familiar with CMake, you're welcome to see if you can get it working (you'll have to run git submodule update --init after cloning), but I am personally waiting for native assets to be ready first.

You're also free to try opencv_dart, a rewrite of this plugin which seems to have much more active maintenance and a specific focus on Flutter

@SkytAsul
Copy link

SkytAsul commented Nov 1, 2024

Thank you for the detailed answer!
I think I am too much of a newcomer in the Dart/Flutter ecosystem to try that by myself. I barely understand how FFI works.
The Native Assets feature seems to have advanced quite well though, I hope it will eventually meet your needs for the opencv package :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants