question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MacOS runtime error (Unable to load shared library 'OpenCvSharpExtern' or one of its dependencies)

See original GitHub issue

Summary of your issue

Hi I tried use OpenCVSharp in my MacOS F# project. I added OpenCvSharp4.runtime.osx.10-15-x64 in my solution

Снимок экрана 2020-05-15 в 16 08 09

Environment

MacOS 10.15.4, Visual Studio for Mac 8.5.6 (build 11)

Example code:

open OpenCvSharp

open System

[<EntryPoint>]
let main argv =
    let src = new Mat("cat.jpg", ImreadModes.Grayscale); // <<----- Exception is here
    // Mat src = Cv2.ImRead("lenna.png", ImreadModes.Grayscale);
    let dst = new Mat();

    let in1 = InputArray.Create(src)
    let in2 = OutputArray.Create(dst)

    Cv2.Canny(in1, in2, 50., 200.);
    use w1 = new Window("src image", src)
    use w2 = new Window("dst image", dst)

    Cv2.WaitKey() |> ignore

    0 // return an integer exit code

Output:

"Unable to load shared library 'OpenCvSharpExtern' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libOpenCvSharpExtern, 1): image not found"

What did you intend to be?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
atkinsonbgcommented, Jan 3, 2022

@vlozhnikov @shimat Could we re-open this one? I’m having the same issue and am not able to resolve it.

My Environment: MacOS Big Sur 11.6, Visual Studio Code v1.63.2, Visual Studio for Mac 2022 Preview v17.0 Build 5186

I’ve tried the following:

  • Installed OpenCV via Brew
  • Per @vlozhnikov’s post I ran the following: brew install wget pkg-config mono-libgdiplus gtk+ ffmpeg glog yasm harfbuzz jpeg libpng libtiff openexr openjpeg metis openblas opencore-amr protobuf tbb webp
  • Per @shimat’s comment, I copied the libOpenCvSharpExtern.dylib library to the root of the project
  • Per @matthewrdev I’ve set that file to Content so it’s copied to the output during a build.
  • Here is my current output folder during a debug session: Screen Shot 2022-01-03 at 11 27 57 AM

However, still getting the error: Screen Shot 2022-01-03 at 11 28 27 AM

Any other thoughts?

2reactions
ccanekecommented, Jul 2, 2020

I’m also on MacOs with exactly the same symptoms described here, but I’ve been stuck on this error for a while.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'OpenCvSharp.NativeMethods' threw an exception. Unable ...
'OpenCvSharp.NativeMethods' threw an exception. Unable to load shared library 'OpenCvSharpExtern' or one of its dependencies., Ubuntu 18.04.
Read more >
MacOS runtime error (Unable to load shared library ' ...
I get Unable to load shared library 'OpenCvSharpExtern' or one of its dependencies constantly while trying to create Mat object.
Read more >
opencvsharp
To use OpenCvSharp, you should add both OpenCvSharp4 and OpenCvSharp4.runtime.* packages to your project. Currently, native bindings for Windows, UWP and Ubuntu ...
Read more >
Net Core App with OpenCV4 in Mac os
DllNotFoundException : Unable to load shared library 'OpenCvSharpExtern' or one of its dependencies. In order to help diagnose loading ...
Read more >
OpenCvSharp.NativeMethods' threw an exception. Unable to ...
[Solved]-'OpenCvSharp.NativeMethods' threw an exception. Unable to load shared library 'OpenCvSharpExtern' or one of its dependencies., Ubuntu 18.04-docker.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found