Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have a problem with running OpenCvShare on the Ubuntu Linux. It keeps saying that libOpenCvSharpExtern is not found.

I have a problem with running OpenCvSharp on my Ubuntu 18.04.1 x64. I have created a .NET Core/Standard solution (Standard is a library project, Core is the runner). The library project references Nuget packages: OpenCvSharp4 (4.0.0.20181225) OpenCvSharp4.runtime.ubuntu.18.04-x64 (4.0.0.20181225).

Then, after a succesfull compilation, I published the runner project using:

dotnet publish -c Release -r ubuntu.18.04-x64

The, when I run the executable on Ubuntu, following error is thrown:

Unhandled Exception: OpenCvSharp.OpenCvSharpException: Failed to create VideoCapture System.TypeInitializationException: The type initializer for 'OpenCvSharp.NativeMethods' threw an exception. OpenCvSharp.OpenCvSharpException: Unable to load shared library 'OpenCvSharpExtern' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libOpenCvSharpExtern: cannot open shared object file: No such file or directory ---> System.DllNotFoundException: Unable to load shared library 'OpenCvSharpExtern' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libOpenCvSharpExtern: cannot open shared object file: No such file or directory

The file libOpenCvSharpExtern.so is in the same path that the executable, I have copied it inside usr/local/lib as well, and id didn't help. Aplication is meant to detect faces based on the camera feed.

I have even succesfult compiled opencv and opencvsharp on Ubunty 18.04 and even then it is not detected. – user3246112 Jan 7, 2019 at 14:47

Okay, I have finally got it running. The problem was in include path. When you execute ldd libOpenCvSharpExtern.so from terminal in path that lib resides, it will output all referenced libraries this one uses. Initially I had full list of "not found" references. All missing libraries were already installed in /usr/local/lib. It turned out, that this path is not a default path where system is looking for libraries. Link to a question on ubuntu forum

After I added export LD_LIBRARY_PATH="/lib:/usr/lib:/usr/local/lib" environment variable and restarted system, everything started working, and using ldd on the libOpenCvSharpExtern.so library showed clearly, that all libraries were found.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.