Mono Android Monodroid 本机库 DllNotFoundException [英] Mono Android Monodroid Native Library DllNotFoundException

查看:42
本文介绍了Mono Android Monodroid 本机库 DllNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 DllImport 在模拟器中使用 Monodroid 获取本地 C/C++ 库.我主要在 Windows/Visual Studio 2010 中进行开发.

I am attempting to get a Native C/C++ library working with Monodroid in the emulator, using DllImport. I am developing mainly in Windows/Visual Studio 2010.

我使用 Android NDK 工具构建了一个原生 C/C++ 库 (ZeroMQ),适用于 x86 和 armeabi 平台,并使用 Ubuntu 虚拟机.这是正确的 - 模拟器的 x86 和真实设备的 armeabi 吗?(在 iPhone/MonoTouch 上肯定就是这种情况——尽管在这种情况下是静态链接的 libzmq.a 文件和 DllImport __Internal)

I have built a native C/C++ library (ZeroMQ) using the Android NDK tools, to both x86 and armeabi platforms, using a Ubuntu virtual machine. Is this correct - x86 for emulator and armeabi for the real device? (This is certainly the case on the iPhone/MonoTouch - though in that case statically linked libzmq.a file and DllImport __Internal)

我已经将 libzmq.so 的 x86 版本添加到我的 MonoDroid 项目目录结构 lib\x86\libzmq.so 下

I have added the x86 version of libzmq.so to my MonoDroid project under the directory structure lib\x86\libzmq.so

当我第一次尝试构建/部署到模拟器时,出现错误无法确定 abi 类型",因此我将 x86 添加到 AndroidNativeLibrary Include="lib\x86\libzmq.so"> 项目项组.然后部署.

When I first attempted to build/deploy to the simulator, I got an error 'cannot determine abi type', so I've added x86 to the AndroidNativeLibrary Include="lib\x86\libzmq.so"> project item group. This then deployed.

我有一个 DllImport 函数可以调用 [DllImport("libzmq"

I have a DllImport for the function to call [DllImport("libzmq"

我尝试过 libzmq.so、lib/x86/libzmq、lib/x86/libzmq.so 等,但后来我调用了 DllImported 方法(在模拟器中运行),我总是得到一个 DllNotFoundException.

I've tried libzmq.so, lib/x86/libzmq, lib/x86/libzmq.so etc, but then I call the DllImported method (running in the emulator), I always get a DllNotFoundException.

谁能给我一些指导?

在阅读另一个说明模拟器使用 armeabi .so 库的支持答案后,我删除了 x86/libzmq 并将我的 lib/armeabi/libzmq.so 添加为 AndroidNativeLibrary.我还删除了项目文件 Abi 条目,并且项目确实构建和部署得很好.

After reading another support answer which states that the emulator uses armeabi .so libraries, I have removed the x86/libzmq and added my lib/armeabi/libzmq.so as an AndroidNativeLibrary. I also removed the project file Abi entry, and indeed the project built and deployed fine.

但是,当我尝试调用 DllImported 函数时,我仍然得到一个 DllNotFoundException.有什么想法吗?

However, I still get a DllNotFoundException when I try to call a DllImported function. Any ideas?

非常感谢

推荐答案

好的,我终于搞定了!无论出于何种原因,ZeroMQ 都无法使用当前/最新的 NDK r7 正确构建.http://www.zeromq.org/build:android 中的说明使用 NDK r6.我还下载了 NDK r5b 的旧版本(这是最容易找到下载的旧版本),并使用它重建 ZeroMQ.结果,它现在可以在模拟器和手机上运行了!

Ok, I finally got it working! For whatever reason, ZeroMQ doesn't build correctly using the current/latest NDK r7. The instructions at http://www.zeromq.org/build:android use NDK r6. I also downloaded an old version of the NDK r5b (it was the easiest old version to find a download for), and rebuilt ZeroMQ using it. Result, it now works on emulator and phone!

这篇关于Mono Android Monodroid 本机库 DllNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆