[Mono-osx] P/Invoke: Can't find dylib no matter what my configuration is

Michael Hutchinson m.j.hutchinson at gmail.com
Sat Feb 13 18:22:03 EST 2010


Yes, Mono on MacOS is currently only 32-bit so can only P/Invoke 32-bit
libraries.

On Feb 13, 2010 1:59 PM, "Kibiz0r" <kibiz0r at gmail.com> wrote:

Here's one I can successfully p/invoke:

otool -L /opt/local/lib/liballeg.dylib
/opt/local/lib/liballeg.dylib:
/opt/local/liballeg-4.2.dylib (compatibility version 4.2.0, current version
4.2.3)
 /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility
version 1.0.0, current version 15.0.0)
/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility
version 2.0.0, current version 152.0.0)


/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility
version 1.0.0, current v...


/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
125.0.0)
/System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
(compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit
(compatibility version 1.0.0, current version 1.0.0)
 /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
(compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/QuickTime.framework/Versions/A/QuickTime
(compatibility version 1.0.0, current version 1591.3.0)
 /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version
227.0.0)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
(compatibility version 1.0.0, current version 44.0.0)
 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
(compatibility version 150.0.0, current version 550.13.0)
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
(compatibility version 1.0.0, current version 38.0.0)
 /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
(compatibility version 300.0.0, current version 751.14.0)


/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility
version 45.0.0, curren...
Here's the output from running my app with logging (good to know how to
do!):

MONO_LOG_LEVEL="debug" MONO_LOG_MASK="dll" mono AllegroSharp.Sandbox.exe
Mono-INFO: DllImport attempting to load:
'/usr/local/lib/liballegro-4.9.16.dylib'.
Mono-INFO: DllImport loading location:
'lib/usr/local/lib/liballegro-4.9.16.dylib.dylib'.
Mono-INFO: DllImport error loading library:
'dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib.dylib, 9): image not
found'.
Mono-INFO: DllImport loading location: 'lib/usr/local/lib/
liballegro-4.9.16.dylib.so'.
Mono-INFO: DllImport error loading library: 'dlopen(lib/usr/local/lib/
liballegro-4.9.16.dylib.so, 9): image not found'.
Mono-INFO: DllImport loading location:
'lib/usr/local/lib/liballegro-4.9.16.dylib.bundle'.
Mono-INFO: DllImport error loading library:
'dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib.bundle, 9): image not
found'.
Mono-INFO: DllImport loading library:
'./lib/usr/local/lib/liballegro-4.9.16.dylib.dylib'.
Mono-INFO: DllImport error loading library
'dlopen(./lib/usr/local/lib/liballegro-4.9.16.dylib.dylib, 9): image not
found'.
Mono-INFO: DllImport loading library: './lib/usr/local/lib/
liballegro-4.9.16.dylib.so'.
Mono-INFO: DllImport error loading library 'dlopen(./lib/usr/local/lib/
liballegro-4.9.16.dylib.so, 9): image not found'.
Mono-INFO: DllImport loading library:
'./lib/usr/local/lib/liballegro-4.9.16.dylib.bundle'.
Mono-INFO: DllImport error loading library
'dlopen(./lib/usr/local/lib/liballegro-4.9.16.dylib.bundle, 9): image not
found'.
Mono-INFO: DllImport loading: '/usr/local/lib/liballegro-4.9.16.dylib'.
Mono-INFO: DllImport error loading library
'dlopen(/usr/local/lib/liballegro-4.9.16.dylib, 9): no suitable image found.
 Did find:
 /usr/local/lib/liballegro-4.9.16.dylib: mach-o, but wrong architecture'.
Mono-INFO: DllImport loading location:
'lib/usr/local/lib/liballegro-4.9.16.dylib.dylib'.
Mono-INFO: DllImport error loading library:
'dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib.dylib, 9): image not
found'.
Mono-INFO: DllImport loading location: 'lib/usr/local/lib/
liballegro-4.9.16.dylib.so'.
Mono-INFO: DllImport error loading library: 'dlopen(lib/usr/local/lib/
liballegro-4.9.16.dylib.so, 9): image not found'.
Mono-INFO: DllImport loading location:
'lib/usr/local/lib/liballegro-4.9.16.dylib.bundle'.
Mono-INFO: DllImport error loading library:
'dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib.bundle, 9): image not
found'.
Mono-INFO: DllImport loading library:
'./lib/usr/local/lib/liballegro-4.9.16.dylib.dylib'.
Mono-INFO: DllImport error loading library
'dlopen(./lib/usr/local/lib/liballegro-4.9.16.dylib.dylib, 9): image not
found'.
Mono-INFO: DllImport loading library: './lib/usr/local/lib/
liballegro-4.9.16.dylib.so'.
Mono-INFO: DllImport error loading library 'dlopen(./lib/usr/local/lib/
liballegro-4.9.16.dylib.so, 9): image not found'.
Mono-INFO: DllImport loading library:
'./lib/usr/local/lib/liballegro-4.9.16.dylib.bundle'.
Mono-INFO: DllImport error loading library
'dlopen(./lib/usr/local/lib/liballegro-4.9.16.dylib.bundle, 9): image not
found'.
Mono-INFO: DllImport loading: 'lib/usr/local/lib/liballegro-4.9.16.dylib'.
Mono-INFO: DllImport error loading library
'dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib, 9): image not found'.

(AllegroSharp.Sandbox.exe:288): Mono-WARNING **: DllImport unable to load
library 'dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib, 9): image not
found'.
Mono-INFO: DllImport attempting to load:
'/usr/local/lib/liballegro-4.9.16.dylib'.
Mono-INFO: DllImport loading location:
'lib/usr/local/lib/liballegro-4.9.16.dylib.dylib'.
Mono-INFO: DllImport error loading library:
'dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib.dylib, 9): image not
found'.
Mono-INFO: DllImport loading location: 'lib/usr/local/lib/
liballegro-4.9.16.dylib.so'.
Mono-INFO: DllImport error loading library: 'dlopen(lib/usr/local/lib/
liballegro-4.9.16.dylib.so, 9): image not found'.
Mono-INFO: DllImport loading location:
'lib/usr/local/lib/liballegro-4.9.16.dylib.bundle'.
Mono-INFO: DllImport error loading library:
'dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib.bundle, 9): image not
found'.
Mono-INFO: DllImport loading library:
'./lib/usr/local/lib/liballegro-4.9.16.dylib.dylib'.
Mono-INFO: DllImport error loading library
'dlopen(./lib/usr/local/lib/liballegro-4.9.16.dylib.dylib, 9): image not
found'.
Mono-INFO: DllImport loading library: './lib/usr/local/lib/
liballegro-4.9.16.dylib.so'.
Mono-INFO: DllImport error loading library 'dlopen(./lib/usr/local/lib/
liballegro-4.9.16.dylib.so, 9): image not found'.
Mono-INFO: DllImport loading library:
'./lib/usr/local/lib/liballegro-4.9.16.dylib.bundle'.
Mono-INFO: DllImport error loading library
'dlopen(./lib/usr/local/lib/liballegro-4.9.16.dylib.bundle, 9): image not
found'.
Mono-INFO: DllImport loading: '/usr/local/lib/liballegro-4.9.16.dylib'.
Mono-INFO: DllImport error loading library
'dlopen(/usr/local/lib/liballegro-4.9.16.dylib, 9): no suitable image found.
 Did find:
 /usr/local/lib/liballegro-4.9.16.dylib: mach-o, but wrong architecture'.
Mono-INFO: DllImport loading location:
'lib/usr/local/lib/liballegro-4.9.16.dylib.dylib'.
Mono-INFO: DllImport error loading library:
'dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib.dylib, 9): image not
found'.
Mono-INFO: DllImport loading location: 'lib/usr/local/lib/
liballegro-4.9.16.dylib.so'.
Mono-INFO: DllImport error loading library: 'dlopen(lib/usr/local/lib/
liballegro-4.9.16.dylib.so, 9): image not found'.
Mono-INFO: DllImport loading location:
'lib/usr/local/lib/liballegro-4.9.16.dylib.bundle'.
Mono-INFO: DllImport error loading library:
'dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib.bundle, 9): image not
found'.
Mono-INFO: DllImport loading library:
'./lib/usr/local/lib/liballegro-4.9.16.dylib.dylib'.
Mono-INFO: DllImport error loading library
'dlopen(./lib/usr/local/lib/liballegro-4.9.16.dylib.dylib, 9): image not
found'.
Mono-INFO: DllImport loading library: './lib/usr/local/lib/
liballegro-4.9.16.dylib.so'.
Mono-INFO: DllImport error loading library 'dlopen(./lib/usr/local/lib/
liballegro-4.9.16.dylib.so, 9): image not found'.
Mono-INFO: DllImport loading library:
'./lib/usr/local/lib/liballegro-4.9.16.dylib.bundle'.
Mono-INFO: DllImport error loading library
'dlopen(./lib/usr/local/lib/liballegro-4.9.16.dylib.bundle, 9): image not
found'.
Mono-INFO: DllImport loading: 'lib/usr/local/lib/liballegro-4.9.16.dylib'.
Mono-INFO: DllImport error loading library
'dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib, 9): image not found'.

(AllegroSharp.Sandbox.exe:288): Mono-WARNING **: DllImport unable to load
library 'dlopen(lib/usr/local/lib/liballegro-4.9.16.dylib, 9): image not
found'.

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

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



On Sat, Feb 13, 2010 at 4:40 AM, Laurent Etiemble <
laurent.etiemble at gmail.com> wrote:
>
> Hello,
>...

_______________________________________________
Mono-osx mailing list
Mono-osx at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-osx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20100213/9eea7fd9/attachment.html 


More information about the Mono-osx mailing list