[Mono-list] P/Invoke on amd64 was :Marshalling problems

James Fitzsimons james.fitzsimons@gmail.com
Sun, 13 Feb 2005 10:44:20 +0000


--=-z0W7DHZJCk7V7N1GGWit
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

Hi Jonathan, Michal,

On Sat, 2005-02-12 at 22:52, Jonathan Pryor wrote:
The question becomes whether or not your programs are 32-bit or 64-bit
> programs, and ditto for your library.
>=20
> Running "file" and "ldd" on your programs and your libraries would help.
Ok, firstly running file and ldd on the Curses program example in my
last email:
 james@athos 07-pinvoke $ file -k /lib64/libncurses.so.5.4=20
/lib64/libncurses.so.5.4: ELF 64-bit LSB shared object, AMD x86-64,
version 1 (SYSV), stripped

james@athos 07-pinvoke $ file -k Curses.exe
Curses.exe: MS Windows PE 32-bit Intel 80386 console executable\012-
MS-DOS executable (EXE), OS/2 or MS Windows

james@athos 07-pinvoke $ file /usr/local/bin/mono
/usr/local/bin/mono: ELF 64-bit LSB executable, AMD x86-64, version 1
(SYSV), for GNU/Linux 2.4.1, dynamically linked (uses shared libs), not
stripped

Now for the actual libraries I am trying to use in my real program:
james@athos 07-pinvoke $ file -k /usr/local/lib/libhighgui-0.9.so.5.0.0=20
/usr/local/lib/libhighgui-0.9.so.5.0.0: ELF 64-bit LSB shared object,
AMD x86-64, version 1 (SYSV), not stripped

james@athos 07-pinvoke $ file -k /usr/local/lib/libopencv-0.9.so.5.0.0 =20
/usr/local/lib/libopencv-0.9.so.5.0.0: ELF 64-bit LSB shared object, AMD
x86-64, version 1 (SYSV), not stripped

(this is a C program which uses the above libraries just fine)
james@athos objRec $ file -k objectRecognition
objectRecognition: ELF 64-bit LSB executable, AMD x86-64, version 1
(SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), not
stripped

Finally, you should try running mono with MONO_LOG_LEVEL=3Dinfo and
> MONO_lOG_MASK=3Ddll.
When I try to run the curses example with logging on I get the following:
Mono-INFO: DllImport loading: 'libncurses'.
Mono-INFO: DllImport error loading library '/usr/lib/libncurses.so:
invalid ELF header'.

(Curses.exe:10129): Mono-WARNING **: DllImport unable to load library
'/usr/lib/libncurses.so: invalid ELF header'.

And with my open computer vision program:
Mono-INFO: DllImport loading: 'libopencv'.
Mono-INFO: DllImport error loading library '/usr/local/lib/libopencv.so:
undefined symbol: __gxx_personality_v0'.

(CvImage.exe:16545): Mono-WARNING **: DllImport unable to load library
'/usr/local/lib/libopencv.so: undefined symbol: __gxx_personality_v0'.

So, it looks like mono finds the libncurses library, but can't load it
for some reason, like wise with the opencv library. The error message is
a bit miss leading in this case. I still don't know how to fix the
problem though.


On Sun, 2005-02-13 at 01:03, Michal Moskal wrote:
> The example works for me without any problems, some other info:
Ok this is strange...I wonder what is different between your environment
and mine that it doesn't work on mine?

> [malekith@r64 07-pinvoke]$ ldd =3Dmono
>         libgthread-2.0.so.0 =3D> /usr/lib64/libgthread-2.0.so.0
> (0x0000002a9566c000)
>         libgmodule-2.0.so.0 =3D> /usr/lib64/libgmodule-2.0.so.0
> (0x0000002a95770000)
>         libdl.so.2 =3D> /lib64/libdl.so.2 (0x0000002a95874000)
>         libglib-2.0.so.0 =3D> /usr/lib64/libglib-2.0.so.0 (0x0000002a9597=
7000)
>         libnsl.so.1 =3D> /lib64/libnsl.so.1 (0x0000002a95afc000)
>         libpthread.so.0 =3D> /lib64/tls/libpthread.so.0 (0x0000002a95c130=
00)
>         libm.so.6 =3D> /lib64/tls/libm.so.6 (0x0000002a95d28000)
>         librt.so.1 =3D> /lib64/tls/librt.so.1 (0x0000002a95eac000)
>         libc.so.6 =3D> /lib64/tls/libc.so.6 (0x0000002a95fb6000)
>         /lib64/ld-linux-x86-64.so.2 (0x0000002a95556000)
james@athos 07-pinvoke $ ldd /usr/local/bin/mono
        libgthread-2.0.so.0 =3D> /usr/lib/libgthread-2.0.so.0
(0x0000002a9566c000)
        libgmodule-2.0.so.0 =3D> /usr/lib/libgmodule-2.0.so.0
(0x0000002a95770000)
        libdl.so.2 =3D> /lib/libdl.so.2 (0x0000002a9589b000)
        libglib-2.0.so.0 =3D> /usr/lib/libglib-2.0.so.0
(0x0000002a9599e000)
        libnsl.so.1 =3D> /lib/libnsl.so.1 (0x0000002a95b22000)
        libpthread.so.0 =3D> /lib/libpthread.so.0 (0x0000002a95c39000)
        libm.so.6 =3D> /lib/libm.so.6 (0x0000002a95dce000)
        librt.so.1 =3D> /lib/librt.so.1 (0x0000002a95f54000)
        libc.so.6 =3D> /lib/libc.so.6 (0x0000002a9606e000)
        /lib64/ld-linux-x86-64.so.2 (0x0000002a95556000)
james@athos 07-pinvoke $
(remember on my system /lib, and /usr/lib) are symlinked to /lib64)

> [malekith@r64 07-pinvoke]$ mono --version
> Mono JIT compiler version 1.1.4, (C) 2002-2004 Novell, Inc and
> Contributors. www.go-mono.com
>         TLS:           __thread
>         GC:            Included Boehm (with typed GC)
>         SIGSEGV      : normal
>         Globalization: none
james@athos 07-pinvoke $ mono --version
Mono JIT compiler version 1.1.4.20050210, (C) 2002-2004 Novell, Inc and
Contributors. www.go-mono.com
        TLS:           __thread
        GC:            Included Boehm (with typed GC)
        SIGSEGV      : normal
        Globalization: none

> [malekith@r64 07-pinvoke]$ uname -a
> Linux roke 2.6.10-0.96 #1 Sun Jan 9 06:11:03 CET 2005 x86_64 0 unknown PL=
D Linux
james@athos 07-pinvoke $ uname -a
Linux athos 2.6.9-gentoo-r14 #8 Sun Jan 30 08:53:55 UTC 2005 x86_64 AMD
Athlon(tm) 64 Processor 3400+ AuthenticAMD GNU/Linux

Thanks very much for your patience guys and thanks for any help you can
provide!

Cheers,
James
--=20
It's 5.50 a.m.... Do you know where your stack pointer is ?

--=-z0W7DHZJCk7V7N1GGWit
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQBCDy9qtf4qL6AoafMRAqPhAKDm5+dkVR6xD81PUAZNMNm7Rx8IoACgh969
u7VT6b+s7ksimWivhV6I+NI=
=leba
-----END PGP SIGNATURE-----

--=-z0W7DHZJCk7V7N1GGWit--