Skip to content

Support Linux arm64 #263

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

Closed
davidpob99 opened this issue Oct 16, 2024 · 4 comments · Fixed by #262
Closed

Support Linux arm64 #263

davidpob99 opened this issue Oct 16, 2024 · 4 comments · Fixed by #262
Labels
question Further information is requested

Comments

@davidpob99
Copy link

Hi, I would like to ask if aarch64 is going to be supported for Linux or if there is a workaround. It would be very useful for developing for embedded devices.

I tried to build a flutter app with a ARM machine (Ubuntu 20.04) with OpenCV 4.7.0 installed but I got the following error:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to load dynamic library 'libopencv_dart.so': libopencv_dart.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      loadNativeLibrary (package:opencv_dart/src/native_lib.dart:37:29)
#3      cimgcodecs (package:opencv_dart/src/native_lib.dart:47:48)
#4      cimgcodecs (package:opencv_dart/src/native_lib.dart)
#5      imread.<anonymous closure>.<anonymous closure> (package:opencv_dart/src/imgcodecs/imgcodecs.dart:29:17)
#6      cvRun (package:opencv_dart/src/core/base.dart:83:76)
#7      imread.<anonymous closure> (package:opencv_dart/src/imgcodecs/imgcodecs.dart:29:5)
#8      cvRunArena (package:opencv_dart/src/core/base.dart:234:31)
#9      imread (package:opencv_dart/src/imgcodecs/imgcodecs.dart:27:10)
#10     main (package:yield_spray/main.dart:18:18)
#11     _runMain.<anonymous closure> (dart:ui/hooks.dart:301:23)
#12     _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
#13     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

Also, I tried to compile the library itself with conan, but I got this error:

======== Input profiles ========
Profile host:
[settings]
arch=armv8
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=9
os=Linux

Profile build:
[settings]
arch=armv8
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=9
os=Linux


======== Computing dependency graph ========
ERROR: conanfile.py (opencv_dart/1.2.5): Error in requirements() method, line 82
        arch = arch_map[platform][str(self.settings.arch)]
        KeyError: 'armv8'

Thanks in advance!

@davidpob99 davidpob99 added the question Further information is requested label Oct 16, 2024
@rainyl
Copy link
Owner

rainyl commented Oct 16, 2024

It's in progress, the stable version, i.e., v1.2.5, doesnt support linux arm64 for now, but i think the branch split-dartcv will work on linux arm64.

Also, conan will be deprecated in the future, i just have no time to update the build instructions.

So, take a look at split-dartcv branch, although it is not finished, it works on linux x64, i didn't test it on linux arm64, if you have any problems, tell me in this issue or in #262

@rainyl
Copy link
Owner

rainyl commented Oct 16, 2024

You need to change the dependency of dartcv at


to

dartcv:
  path: ../dartcv

I have tried to publish the dartcv package but found there was another package with similar name dart_cv, pub.dev doesn't allow publishing packages with similar names, and I am busy recently, so the dependency was not corrected.

@davidpob99
Copy link
Author

davidpob99 commented Oct 17, 2024

Thank you for you quick response. I followed the instructions and it works in a machine with Ubuntu 22.04.
However, in another machine with Ubuntu 20.04 it raises the following error:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to load dynamic library 'libdartcv.so': libdartcv.so: undefined symbol: __libc_single_threaded
#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      loadNativeLibrary (package:dartcv/src/native_lib.dart:36:29)
#3      cimgcodecs (package:dartcv/src/native_lib.dart:46:48)
#4      cimgcodecs (package:dartcv/src/native_lib.dart)
#5      imread.<anonymous closure>.<anonymous closure> (package:dartcv/src/imgcodecs/imgcodecs.dart:29:17)
#6      cvRun (package:dartcv/src/core/base.dart:83:76)
#7      imread.<anonymous closure> (package:dartcv/src/imgcodecs/imgcodecs.dart:29:5)
#8      cvRunArena (package:dartcv/src/core/base.dart:234:31)
#9      imread (package:dartcv/src/imgcodecs/imgcodecs.dart:27:10)
#10     main (package:yield_spray/main.dart:13:18)
#11     _runMain.<anonymous closure> (dart:ui/hooks.dart:301:23)
#12     _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
#13     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

I searched on the Internet and it seems to be a problem with glibc, in 20.04 the version of that library is < 2.32 (it is 2.31) and the function __libc_single_threaded is not defined.

Maybe is necessary to add that dependency in README?

Refs: wch/r-debug#25, https://stackoverflow.com/questions/76727663/undefined-reference-to-pthread-using-cmake

@rainyl
Copy link
Owner

rainyl commented Oct 18, 2024

@davidpob99 glad it helps.

I searched on the Internet and it seems to be a problem with glibc, in 20.04 the version of that library is < 2.32 (it is 2.31) and the function __libc_single_threaded is not defined.

Yes, the opencv static libs were cross-compiled on ubuntu 22.04, whose libc version was 2.35 (https://ubuntu.pkgs.org/22.04/ubuntu-main-amd64/libc6-dev-arm64-cross_2.35-0ubuntu1cross3_all.deb.html).

Maybe is necessary to add that dependency in README?

Yes, I will add the requirements to README. Thanks~

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

Successfully merging a pull request may close this issue.

2 participants