Mono Android Monodroid Native Library DllNotFoundException

前端 未结 3 1232
庸人自扰
庸人自扰 2021-02-06 19:23

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.

I have built

相关标签:
3条回答
  • 2021-02-06 19:27

    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!

    0 讨论(0)
  • 2021-02-06 19:38

    I don't have any immediate ideas why it isn't working for you; [DllImport("zmq")] should work.

    The SanityTests sample exercises the DllImport attribute.

    • The DllImport: https://github.com/xamarin/monodroid-samples/blob/master/SanityTests/Hello.cs#L240
    • The Android.mk to build libfoo.so: https://github.com/xamarin/monodroid-samples/blob/master/SanityTests/jni/Android.mk
    • Building libfoo.so by calling ndk-build: https://github.com/xamarin/monodroid-samples/blob/master/SanityTests/SanityTests.csproj#L82
    • Including libfoo.so into the .apk: https://github.com/xamarin/monodroid-samples/blob/master/SanityTests/SanityTests.csproj#L96
    0 讨论(0)
  • 2021-02-06 19:46

    (This is a repeat of my reply to your email in the ZeroMQ mailing list).

    This error could be caused by using an incorrect platform target in your Mono project. I'm not sure if Mono/MonoDevelop supports this, but you probably need to create an ARM platform target, as opposed to x86/x64/Any CPU.

    You would experience the same errors if you tried to do P/Invoke interop between an x64-targeted assembly with an x86 native library or vice-versa.

    If you're using the clrzmq bindings for bridging Mono and libzmq, you will need to create a new platform target for ARM and rebuild the bindings. The solution only defines x86 and x64 platform targets currently.

    0 讨论(0)
提交回复
热议问题