简体   繁体   English

在Mac上的Mono中使用DllImport进行DllNotFoundException:错误的体系结构

[英]DllNotFoundException with DllImport in Mono on Mac: wrong architecture

I'm trying to interop with the ImageMagick library in Mono on a Mac. 我正试图在Mac上与Mono中的ImageMagick库互操作。 I installed the ImageMagick library with MacPorts and have verified that the file libMagickWand.dylib exists in the directory /opt/local/lib . 我使用MacPorts安装了ImageMagick库,并验证了文件libMagickWand.dylib是否存在于目录/ opt / local / lib中 I've also created a soft link to that file in the directory /usr/local/lib . 我还在/ usr / local / lib目录中创建了一个指向该文件的软链接。

Here's my DllImport statement: 这是我的DllImport声明:

[DllImport("libMagickWand", EntryPoint = "MagickWandGenesis")]
static extern void WandGenesis();

Here's my App.config: 这是我的App.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <dllmap dll="libMagickWand" target="/opt/local/lib/libMagickWand.dylib" />
</configuration>

And, at the call to WandGenesis(); 并且,在召唤WandGenesis(); , I get a DllNotFoundException , with the message 'libMagickWand'. ,我得到一个DllNotFoundException ,消息'libMagickWand'。

I've read this page and I think I'm following all the rules. 我已阅读此页面 ,我认为我遵循所有规则。 Is there anything else I can try? 还有什么我可以尝试的吗?

Update: 更新:

I ran the .exe with MONO_LOG_LEVEL=debug. 我使用MONO_LOG_LEVEL = debug运行.exe。 Here is the pertinent information: 以下是相关信息:

Mono: DllImport error loading library 'dlopen(/opt/local/lib/libMagickWand.5.dylib, 9):
no suitable image found.
Did find: /opt/local/lib/libMagickWand.5.dylib: mach-o, but wrong architecture'.

wrong architecture : I'm running Snow Leopard in 32-bit mode and always have. 错误的架构 :我在32位模式下运行Snow Leopard并且总是有。 I installed ImageMagick with MacPorts, and I installed Mono with the Mac package from mono-project.com. 我在MacPorts上安装了ImageMagick,并使用mono-project.com的Mac软件包安装了Mono。 What would have been compiled with a different architecture? 用不同的架构编译什么?

Update: 更新:

I think I found my problem: 我想我发现了我的问题:

MacBook-Pro:lib ken$ lipo -info libMagickWand.5.dylib
Non-fat file: libMagickWand.5.dylib is architecture: x86_64

Update: 更新:

...but I'm still having issues. ......但我还有问题。 I can't seem to figure out how to compile ImageMagick with i386 architecture. 我似乎无法弄清楚如何使用i386架构编译ImageMagick。 When I try to do so using flags, it complains about other libraries that were compiled as 64-bit. 当我尝试使用标志时,它会抱怨其他编译为64位的库。

Update: 更新:

Mono on Mac OS X is 32 bit (at least usually, you can confirm that with mono --version ) and you are trying to link with 64bit binary which is not possible. Mac OS X上的Mono是32位(至少通常,您可以通过mono --version来确认)并且您尝试使用64位二进制文​​件进行链接,这是不可能的。 You have to provide 32-bit binary (or use 64-bit Mono). 您必须提供32位二进制(或使用64位单声道)。


Do you have the error even when only the library's file name is in the target and the library is placed appropriately (or the DYLD_LIBRARY_PATH set)? 即使只有库的文件名在目标中并且库已正确放置(或设置了DYLD_LIBRARY_PATH),您是否有错误? In such case please provide the output of mono executed with MONO_LOG_LEVEL=debug. 在这种情况下,请提供使用MONO_LOG_LEVEL = debug执行的mono输出。

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

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