简体   繁体   English

覆盆子pi上的mono在共享对象(.so)文件的DLLImport上引发DLLNotFoundException

[英]mono on raspberry pi throws DLLNotFoundException at DLLImport of shared object (.so) file

I am currently working with the mono run-time on a raspberry pi (B). 我目前正在树莓派(B)上使用单声道运行时。 I use Visual Studio Express 2012 for Windows Desktop. 我将Visual Studio Express 2012用于Windows桌面。 What i basically want to achieve is to save a series of pictures from a webcam (Logitech C270) to a .jpg file. 我基本上想要实现的是将一系列图像从网络摄像头(Logitech C270)保存到.jpg文件。

I found a project that seems to do just what i need: http://www.raspberry-sharp.org/romain-flechner/2012/10/projects/use-a-webcam-plugged-in-a-raspberry-pi-with-mono-in-c-using-raspberrycam/ So I installed it via NuGet into my project and copied the code sample: 我发现一个似乎可以满足我需要的项目: http : //www.raspberry-sharp.org/romain-flechner/2012/10/projects/use-a-webcam-plugged-in-a-raspberry-pi -with-mono-in-c-using-raspberrycam /所以我通过NuGet将其安装到我的项目中并复制了代码示例:

Cameras cameras = Cameras.DeclareDevice()
.Named(“Camera 1″).WithDevicePath(“/dev/video0″)
.Memorize();

cameras.Get(“Camera 1″).SavePicture(new PictureSize(640, 480), “/var/www/test.jpg”, 20);

As written in the instructions on the project page, I copied the RaspberryCam.so into the /lib directory (I also copied it to /Lib for that matter). 按照项目页面上的说明,我将RaspberryCam.so复制到了/ lib目录中(为此我也将其复制到了/ Lib中)。 Then I downloaded the built files (my.exe, RaspberryCam.dll) to my Raspberry PI. 然后,我将生成的文件(my.exe,RaspberryCam.dll)下载到我的Raspberry PI。

Now here's my problem: Whenever I try to execute my program with mono I get a DllNotFoundException for RaspberryCam.so. 现在这是我的问题:每当我尝试使用mono执行程序时,我都会为RaspberryCam.so收到DllNotFoundException。

I added my project path to /etc/ld.so.conf and ran ldconfig but that doesn't help. 我将项目路径添加到/etc/ld.so.conf并运行ldconfig,但这无济于事。

I also tried running mono in debug mode (MONO_LOG_LEVEL="debug" MONO_LOG_MASK="dll" mono /var/www/my.exe) and it appears to be searching for "libRaspberryCam.so", so I copied the /lib/RaspberryCam.so to /lib/libRaspberryCam.so, but that didn't change anything either. 我还尝试了在调试模式下运行mono(MONO_LOG_LEVEL =“ debug” MONO_LOG_MASK =“ dll” mono /var/www/my.exe),它似乎正在搜索“ libRaspberryCam.so”,因此我复制了/ lib / RaspberryCam .so到/lib/libRaspberryCam.so,但这也没有任何改变。

BTW i changed the access rights of the .so file to 755 (read, write, execute for root and read, execute for world). 顺便说一句,我将.so文件的访问权限更改为755(读,写,为root执行和读,为world执行)。

To be honest with you, I don't really know much about DLL-Import stuff so i could just be making some dumb mistake here. 老实说,我对DLL导入的东西了解不多,所以我可能在这里犯了一些愚蠢的错误。 However I've already written a comment in the raspberrycam project page last week but I didn't get any answer yet. 但是上周我已经在raspberrycam项目页面上写过评论,但是我还没有得到任何答案。

Can anyone help me with this matter? 谁能帮我解决这个问题?

Thanks Dominik 谢谢多米尼克

Edit: The Code of the actual DLLImport is from the Raspberrycam project "RaspberryCamInterop.cs": 编辑:实际DLLImport的代码来自Raspberrycam项目“ RaspberryCamInterop.cs”:

using System;
using System.Runtime.InteropServices;

namespace RaspberryCam.Interop
{
    public class RaspberryCamInterop
    {
        [DllImport("RaspberryCam.so", EntryPoint = "TakePicture")]
        public static extern PictureBuffer TakePicture(string device, uint width, uint height, uint jpegQuantity);

        [DllImport("RaspberryCam.so", EntryPoint = "OpenCameraStream")]
        public static extern IntPtr OpenCameraStream(string device, uint width, uint height, uint fps);

        [DllImport("RaspberryCam.so", EntryPoint = "CloseCameraStream")]
        public static extern void CloseCameraStream(IntPtr src);

        [DllImport("RaspberryCam.so", EntryPoint = "ReadVideoFrame")]
        public static extern PictureBuffer ReadVideoFrame(IntPtr src, uint jpegQuantity);

        [DllImport("RaspberryCam.so", EntryPoint = "GrabVideoFrame")]
        public static extern PictureBuffer GrabVideoFrame(IntPtr src);
    }
}

Edit 2: It appears to be some problem with the soft-float wheezy. 编辑2:似乎是浮游式喘息的问题。 I have now installed the standard hard-float raspbian (as it was written in the guide on the project page: http://www.raspberry-sharp.org/eric-bezine/2012/10/mono-framework/installing-mono-raspberry-pi/ ) and it works, well it isn't particularly fast but it does save a picture. 我现在已经安装了标准的硬浮动raspbian(如项目页面上的指南中所写: http ://www.raspberry-sharp.org/eric-bezine/2012/10/mono-framework/installing-mono -raspberry-pi / ),并且效果不错,虽然速度不是特别快,但确实可以保存图片。 I find it a bit irritating that they used the hard-float raspbian image even though mono isn't compatible with the ARM hard-float abi. 我感到有些恼火的是,即使mono与ARM硬浮动abi不兼容,他们也使用了硬浮动的树莓派图像。 In the mono installation guide they don't mention any hard-float patch either and I've even found some workarounds in the source code of the RaspberryCam project, so they did notice the bugs related with running mono on hard-float abi. 在mono安装指南中,他们也没有提到任何硬浮动补丁,而且我什至在RaspberryCam项目的源代码中发现了一些变通办法,因此他们的确注意到与在硬浮动abi上运行mono有关的错误。

Snippet from "PicturesCache.cs" 来自“ PicturesCache.cs”的摘录

//Timespan bug with ARM version of MONO, so we will use int in milliseconds
private readonly int duration;

However, I'm going to stick with the soft-float wheezy and just use a tool called uvccapture in collaboration with some shell scripts to do the job. 但是,我将坚持使用软浮起的微调,仅使用与一些shell脚本配合使用的名为uvccapture的工具来完成这项工作。

Yet I am still grateful for any advice or solution from you. 但是,我仍然感谢您的任何建议或解决方案。

What is working for me: I copied the lib in the .exe folder and renamed it as libRaspberryCam.so. 对我有用的是:我将lib复制到.exe文件夹中,并将其重命名为libRaspberryCam.so。

On my side, quality is very poor. 在我这边,质量很差。 I can't configure the camera from this lib. 我无法从此库配置相机。

Did you try with 你尝试过

$sudo make
$sudo make install

?

Verify acces right to RaspberryCam.so and fix it a chmod. 验证对RaspberryCam.so的访问权限,并将其修复为chmod。

Bye 再见

我有同样的异常,通过将RaspberryCam.so复制到/ usr / lib(而不是根目录/ lib)来解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM