Here&#39;s one I can successfully p/invoke:<div><br></div><div><div>otool -L /opt/local/lib/liballeg.dylib </div><div>/opt/local/lib/liballeg.dylib:</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>/opt/local/liballeg-4.2.dylib (compatibility version 4.2.0, current version 4.2.3)</div>

<div><span class="Apple-tab-span" style="white-space:pre">        </span>/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 15.0.0)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 152.0.0)</div>

<div><span class="Apple-tab-span" style="white-space:pre">        </span>/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.0)</div>

<div><span class="Apple-tab-span" style="white-space:pre">        </span>/System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio (compatibility version 1.0.0, current version 1.0.0)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>/System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit (compatibility version 1.0.0, current version 1.0.0)</div>

<div><span class="Apple-tab-span" style="white-space:pre">        </span>/System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 1.0.0)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>/System/Library/Frameworks/QuickTime.framework/Versions/A/QuickTime (compatibility version 1.0.0, current version 1591.3.0)</div>

<div><span class="Apple-tab-span" style="white-space:pre">        </span>/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 227.0.0)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 44.0.0)</div>

<div><span class="Apple-tab-span" style="white-space:pre">        </span>/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 550.13.0)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 38.0.0)</div>

<div><span class="Apple-tab-span" style="white-space:pre">        </span>/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 751.14.0)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1038.25.0)</div>

<div><br></div><div>Here&#39;s the output from running my app with logging (good to know how to do!):</div><div><br></div><div><div><div>MONO_LOG_LEVEL=&quot;debug&quot; MONO_LOG_MASK=&quot;dll&quot; mono AllegroSharp.Sandbox.exe</div>

<div>Mono-INFO: DllImport attempting to load: &#39;/usr/local/lib/liballegro-4.9.16.dylib&#39;.</div><div>Mono-INFO: DllImport loading location: &#39;lib/usr/local/lib/liballegro-4.9.16.dylib.dylib&#39;.</div><div>Mono-INFO: DllImport error loading library: &#39;dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib.dylib, 9): image not found&#39;.</div>

<div>Mono-INFO: DllImport loading location: &#39;lib/usr/local/lib/<a href="http://liballegro-4.9.16.dylib.so">liballegro-4.9.16.dylib.so</a>&#39;.</div><div>Mono-INFO: DllImport error loading library: &#39;dlopen(lib/usr/local/lib/<a href="http://liballegro-4.9.16.dylib.so">liballegro-4.9.16.dylib.so</a>, 9): image not found&#39;.</div>

<div>Mono-INFO: DllImport loading location: &#39;lib/usr/local/lib/liballegro-4.9.16.dylib.bundle&#39;.</div><div>Mono-INFO: DllImport error loading library: &#39;dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib.bundle, 9): image not found&#39;.</div>

<div>Mono-INFO: DllImport loading library: &#39;./lib/usr/local/lib/liballegro-4.9.16.dylib.dylib&#39;.</div><div>Mono-INFO: DllImport error loading library &#39;dlopen(./lib/usr/local/lib/liballegro-4.9.16.dylib.dylib, 9): image not found&#39;.</div>

<div>Mono-INFO: DllImport loading library: &#39;./lib/usr/local/lib/<a href="http://liballegro-4.9.16.dylib.so">liballegro-4.9.16.dylib.so</a>&#39;.</div><div>Mono-INFO: DllImport error loading library &#39;dlopen(./lib/usr/local/lib/<a href="http://liballegro-4.9.16.dylib.so">liballegro-4.9.16.dylib.so</a>, 9): image not found&#39;.</div>

<div>Mono-INFO: DllImport loading library: &#39;./lib/usr/local/lib/liballegro-4.9.16.dylib.bundle&#39;.</div><div>Mono-INFO: DllImport error loading library &#39;dlopen(./lib/usr/local/lib/liballegro-4.9.16.dylib.bundle, 9): image not found&#39;.</div>

<div>Mono-INFO: DllImport loading: &#39;/usr/local/lib/liballegro-4.9.16.dylib&#39;.</div><div>Mono-INFO: DllImport error loading library &#39;dlopen(/usr/local/lib/liballegro-4.9.16.dylib, 9): no suitable image found.  Did find:</div>

<div><span class="Apple-tab-span" style="white-space:pre">        </span>/usr/local/lib/liballegro-4.9.16.dylib: mach-o, but wrong architecture&#39;.</div><div>Mono-INFO: DllImport loading location: &#39;lib/usr/local/lib/liballegro-4.9.16.dylib.dylib&#39;.</div>

<div>Mono-INFO: DllImport error loading library: &#39;dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib.dylib, 9): image not found&#39;.</div><div>Mono-INFO: DllImport loading location: &#39;lib/usr/local/lib/<a href="http://liballegro-4.9.16.dylib.so">liballegro-4.9.16.dylib.so</a>&#39;.</div>

<div>Mono-INFO: DllImport error loading library: &#39;dlopen(lib/usr/local/lib/<a href="http://liballegro-4.9.16.dylib.so">liballegro-4.9.16.dylib.so</a>, 9): image not found&#39;.</div><div>Mono-INFO: DllImport loading location: &#39;lib/usr/local/lib/liballegro-4.9.16.dylib.bundle&#39;.</div>

<div>Mono-INFO: DllImport error loading library: &#39;dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib.bundle, 9): image not found&#39;.</div><div>Mono-INFO: DllImport loading library: &#39;./lib/usr/local/lib/liballegro-4.9.16.dylib.dylib&#39;.</div>

<div>Mono-INFO: DllImport error loading library &#39;dlopen(./lib/usr/local/lib/liballegro-4.9.16.dylib.dylib, 9): image not found&#39;.</div><div>Mono-INFO: DllImport loading library: &#39;./lib/usr/local/lib/<a href="http://liballegro-4.9.16.dylib.so">liballegro-4.9.16.dylib.so</a>&#39;.</div>

<div>Mono-INFO: DllImport error loading library &#39;dlopen(./lib/usr/local/lib/<a href="http://liballegro-4.9.16.dylib.so">liballegro-4.9.16.dylib.so</a>, 9): image not found&#39;.</div><div>Mono-INFO: DllImport loading library: &#39;./lib/usr/local/lib/liballegro-4.9.16.dylib.bundle&#39;.</div>

<div>Mono-INFO: DllImport error loading library &#39;dlopen(./lib/usr/local/lib/liballegro-4.9.16.dylib.bundle, 9): image not found&#39;.</div><div>Mono-INFO: DllImport loading: &#39;lib/usr/local/lib/liballegro-4.9.16.dylib&#39;.</div>

<div>Mono-INFO: DllImport error loading library &#39;dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib, 9): image not found&#39;.</div><div><br></div><div>(AllegroSharp.Sandbox.exe:288): Mono-WARNING **: DllImport unable to load library &#39;dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib, 9): image not found&#39;.</div>

<div>Mono-INFO: DllImport attempting to load: &#39;/usr/local/lib/liballegro-4.9.16.dylib&#39;.</div><div>Mono-INFO: DllImport loading location: &#39;lib/usr/local/lib/liballegro-4.9.16.dylib.dylib&#39;.</div><div>Mono-INFO: DllImport error loading library: &#39;dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib.dylib, 9): image not found&#39;.</div>

<div>Mono-INFO: DllImport loading location: &#39;lib/usr/local/lib/<a href="http://liballegro-4.9.16.dylib.so">liballegro-4.9.16.dylib.so</a>&#39;.</div><div>Mono-INFO: DllImport error loading library: &#39;dlopen(lib/usr/local/lib/<a href="http://liballegro-4.9.16.dylib.so">liballegro-4.9.16.dylib.so</a>, 9): image not found&#39;.</div>

<div>Mono-INFO: DllImport loading location: &#39;lib/usr/local/lib/liballegro-4.9.16.dylib.bundle&#39;.</div><div>Mono-INFO: DllImport error loading library: &#39;dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib.bundle, 9): image not found&#39;.</div>

<div>Mono-INFO: DllImport loading library: &#39;./lib/usr/local/lib/liballegro-4.9.16.dylib.dylib&#39;.</div><div>Mono-INFO: DllImport error loading library &#39;dlopen(./lib/usr/local/lib/liballegro-4.9.16.dylib.dylib, 9): image not found&#39;.</div>

<div>Mono-INFO: DllImport loading library: &#39;./lib/usr/local/lib/<a href="http://liballegro-4.9.16.dylib.so">liballegro-4.9.16.dylib.so</a>&#39;.</div><div>Mono-INFO: DllImport error loading library &#39;dlopen(./lib/usr/local/lib/<a href="http://liballegro-4.9.16.dylib.so">liballegro-4.9.16.dylib.so</a>, 9): image not found&#39;.</div>

<div>Mono-INFO: DllImport loading library: &#39;./lib/usr/local/lib/liballegro-4.9.16.dylib.bundle&#39;.</div><div>Mono-INFO: DllImport error loading library &#39;dlopen(./lib/usr/local/lib/liballegro-4.9.16.dylib.bundle, 9): image not found&#39;.</div>

<div>Mono-INFO: DllImport loading: &#39;/usr/local/lib/liballegro-4.9.16.dylib&#39;.</div><div>Mono-INFO: DllImport error loading library &#39;dlopen(/usr/local/lib/liballegro-4.9.16.dylib, 9): no suitable image found.  Did find:</div>

<div><span class="Apple-tab-span" style="white-space:pre">        </span>/usr/local/lib/liballegro-4.9.16.dylib: mach-o, but wrong architecture&#39;.</div><div>Mono-INFO: DllImport loading location: &#39;lib/usr/local/lib/liballegro-4.9.16.dylib.dylib&#39;.</div>

<div>Mono-INFO: DllImport error loading library: &#39;dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib.dylib, 9): image not found&#39;.</div><div>Mono-INFO: DllImport loading location: &#39;lib/usr/local/lib/<a href="http://liballegro-4.9.16.dylib.so">liballegro-4.9.16.dylib.so</a>&#39;.</div>

<div>Mono-INFO: DllImport error loading library: &#39;dlopen(lib/usr/local/lib/<a href="http://liballegro-4.9.16.dylib.so">liballegro-4.9.16.dylib.so</a>, 9): image not found&#39;.</div><div>Mono-INFO: DllImport loading location: &#39;lib/usr/local/lib/liballegro-4.9.16.dylib.bundle&#39;.</div>

<div>Mono-INFO: DllImport error loading library: &#39;dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib.bundle, 9): image not found&#39;.</div><div>Mono-INFO: DllImport loading library: &#39;./lib/usr/local/lib/liballegro-4.9.16.dylib.dylib&#39;.</div>

<div>Mono-INFO: DllImport error loading library &#39;dlopen(./lib/usr/local/lib/liballegro-4.9.16.dylib.dylib, 9): image not found&#39;.</div><div>Mono-INFO: DllImport loading library: &#39;./lib/usr/local/lib/<a href="http://liballegro-4.9.16.dylib.so">liballegro-4.9.16.dylib.so</a>&#39;.</div>

<div>Mono-INFO: DllImport error loading library &#39;dlopen(./lib/usr/local/lib/<a href="http://liballegro-4.9.16.dylib.so">liballegro-4.9.16.dylib.so</a>, 9): image not found&#39;.</div><div>Mono-INFO: DllImport loading library: &#39;./lib/usr/local/lib/liballegro-4.9.16.dylib.bundle&#39;.</div>

<div>Mono-INFO: DllImport error loading library &#39;dlopen(./lib/usr/local/lib/liballegro-4.9.16.dylib.bundle, 9): image not found&#39;.</div><div>Mono-INFO: DllImport loading: &#39;lib/usr/local/lib/liballegro-4.9.16.dylib&#39;.</div>

<div>Mono-INFO: DllImport error loading library &#39;dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib, 9): image not found&#39;.</div><div><br></div><div>(AllegroSharp.Sandbox.exe:288): Mono-WARNING **: DllImport unable to load library &#39;dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib, 9): image not found&#39;.</div>

<div><br></div><div>Unhandled Exception: System.DllNotFoundException: /usr/local/lib/liballegro-4.9.16.dylib</div><div>  at (wrapper managed-to-native) AllegroSharp.Allegro:GetVersion ()</div><div>  at AllegroSharp.Sandbox.MainClass.Main (System.String[] args) [0x00000] in &lt;filename unknown&gt;:0</div>

<div><br></div><div>I&#39;m assuming wrong architecture means the library was built 64-bit but should be 32. (or vice-versa?) I&#39;m on snow leopard. This sounds more like a build system issue than a p/invoke issue, so I&#39;ll pursue this with the Allegro developers. Thanks for your help.</div>

</div></div><br><div class="gmail_quote">On Sat, Feb 13, 2010 at 4:40 AM, Laurent Etiemble <span dir="ltr">&lt;<a href="mailto:laurent.etiemble@gmail.com">laurent.etiemble@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Hello,<br><br>The first line of the otool output seems suspicious: usually, the first line is the absolute path of the library, or contains a path lookup directive (@executable_path for example).<br><br>- Can you post the otool output of a library that you can successfully p/invoke ?<br>



- Have you tried to use the following command line to see what is going on ?<br><br> MONO_LOG_LEVEL=&quot;debug&quot; MONO_LOG_MASK=&quot;dll&quot; mono MyProgram.exe<br><br>Regards, Laurent Etiemble.<br><br><div class="gmail_quote">



2010/2/13 Kibiz0r <span dir="ltr">&lt;<a href="mailto:kibiz0r@gmail.com" target="_blank">kibiz0r@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">

<div><div></div><div class="h5">

<div>I&#39;m at my wit&#39;s end. I can p/invoke other dylibs just fine, and I can use this dylib just fine from C, but something isn&#39;t working here.</div><div><br></div><div>The dylib is here: /usr/local/lib/liballegro-4.9.16.dylib</div>





<div><div><br></div><div>My binding looks like this:</div><div><div>public class Allegro</div><div>{</div><div>    [DllImport(&quot;allegro-4.9.16.dll&quot;, EntryPoint = &quot;al_get_allegro_version&quot;)]</div><div>    public static extern uint GetVersion();</div>





<div>}</div></div><div><br></div><div>And I&#39;ve got a .config like this:</div><div>&lt;dllmap dll=&quot;allegro-4.9.16.dll&quot; target=&quot;/usr/local/lib/liballegro-4.9.16.dylib&quot; os=&quot;osx&quot; /&gt;</div>




<div>
<br></div><div>When I try to do Allegro.GetVersion(), I get System.DllNotFoundException: /usr/local/lib/liballegro-4.9.16.dylib</div><div><br></div><div>This is the output from otool -L /usr/local/lib/liballegro-4.9.16.dylib:</div>





<div><div>/usr/local/lib/liballegro-4.9.16.dylib:</div><div><span style="white-space:pre">        </span>liballegro-4.9.16.dylib (compatibility version 0.0.0, current version 0.0.0)</div><div><span style="white-space:pre">        </span>/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1038.25.0)</div>





<div><span style="white-space:pre">        </span>/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)</div><div><span style="white-space:pre">        </span>/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)</div>





<div><span style="white-space:pre">        </span>/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)</div><div><span style="white-space:pre">        </span>/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)</div>





<div><span style="white-space:pre">        </span>/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.0)</div><div><br></div><div>I&#39;ve tried using various combinations of DllImport and dllmap, but nothing works.</div>





<div>I tried setting DYLD_LIBRARY_PATH, but that didn&#39;t help. (I can p/invoke other dylibs from the same directory anyway.)</div></div><div><br>-- <br>Michael Harrington | Software Apprentice<br>Atomic Object | <a href="http://atomicobject.com" target="_blank">http://atomicobject.com</a><br>





[Ph] +1 616 776 6020 [Fx] +1 616 776 6015<br>
</div></div>
<br></div></div>_______________________________________________<br>
Mono-osx mailing list<br>
<a href="mailto:Mono-osx@lists.ximian.com" target="_blank">Mono-osx@lists.ximian.com</a><br>
<a href="http://lists.ximian.com/mailman/listinfo/mono-osx" target="_blank">http://lists.ximian.com/mailman/listinfo/mono-osx</a><br>
<br></blockquote></div><br>
</blockquote></div><br><br clear="all"><br>-- <br>Michael Harrington | Software Apprentice<br>Atomic Object | <a href="http://atomicobject.com">http://atomicobject.com</a><br>[Ph] +1 616 776 6020 [Fx] +1 616 776 6015<br>


</div>