[Mono-list] Unable to DllImporting libc.so

Adam Keys akeys@post.cis.smu.edu
21 Nov 2002 20:40:54 -0600


--=-l6tmt4N3bZp+HIrGFhC1
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

I am trying to implement a POSIX wrapper and so I need to DllImport
libc.so.  Whenever I run my code[1] mono outputs the following:

** (process:18635): WARNING **: Failed to load library libc.so (libc.so)

I've tried setting MONO_PATH and LD_LIBRARY_PATH to /usr/lib but I am
still unable to load libc.so.  Copying libc.so to the working directory
doesn't seem to help either.

I've attached[2] strace output of running mono.  Any idea what's going
on here?  It looks like it fails to load ./libc.so and then tries
/usr/lib/libc.so, successfully opens the file but then fails on calls to
access(2).

[1] http://trmk.org/~adam/mono/Posix.cs
[2] Full trace output at http://trmk.org/~adam/mono/strace.out

Thanks,
-- 
AKK~
http://trmk.org/~adam/blog

--=-l6tmt4N3bZp+HIrGFhC1
Content-Disposition: attachment; filename=trace.txt
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=trace.txt; charset=ISO-8859-1

open("PosixTest.exe", O_RDONLY|O_LARGEFILE) =3D 6
brk(0x8230000)                          =3D 0x8230000
fstat64(6, {st_mode=3DS_IFREG|0644, st_size=3D2048, ...}) =3D 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0=
) =3D 0x40016000
read(6, "MZ\0\0\4\0\0\0\4\0\0\0\377\377\0\0\270\0\0\0\0\0\0\0@\0"..., 4096)=
 =3D 2048
mmap2(NULL, 4096, PROT_READ, MAP_PRIVATE, 6, 0) =3D 0x40017000
mmap2(NULL, 4096, PROT_READ, MAP_PRIVATE, 6, 0) =3D 0x40018000
_llseek(6, 0, [0], SEEK_SET)            =3D 0
read(6, "MZ\0\0\4\0\0\0\4\0\0\0\377\377\0\0\270\0\0\0\0\0\0\0@\0"..., 4096)=
 =3D 2048
mmap2(NULL, 4096, PROT_READ, MAP_PRIVATE, 6, 0) =3D 0x40019000
open("./Posix.dll", O_RDONLY|O_LARGEFILE) =3D 7
brk(0x8231000)                          =3D 0x8231000
fstat64(7, {st_mode=3DS_IFREG|0644, st_size=3D2048, ...}) =3D 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0=
) =3D 0x4001a000
read(7, "MZ\0\0\4\0\0\0\4\0\0\0\377\377\0\0\270\0\0\0\0\0\0\0@\0"..., 4096)=
 =3D 2048
mmap2(NULL, 4096, PROT_READ, MAP_PRIVATE, 7, 0) =3D 0x4001b000
mmap2(NULL, 4096, PROT_READ, MAP_PRIVATE, 7, 0) =3D 0x4001c000
_llseek(7, 0, [0], SEEK_SET)            =3D 0
read(7, "MZ\0\0\4\0\0\0\4\0\0\0\377\377\0\0\270\0\0\0\0\0\0\0@\0"..., 4096)=
 =3D 2048
mmap2(NULL, 4096, PROT_READ, MAP_PRIVATE, 7, 0) =3D 0x4001d000
open("./libc.so", O_RDONLY|O_LARGEFILE) =3D -1 ENOENT (No such file or dire=
ctory)
brk(0x8234000)                          =3D 0x8234000
getpid()                                =3D 18635
access("libc.so", F_OK)                 =3D -1 ENOENT (No such file or dire=
ctory)
stat64("libc.so", 0xbffff4e8)           =3D -1 ENOENT (No such file or dire=
ctory)
access("libc.so.so", F_OK)              =3D -1 ENOENT (No such file or dire=
ctory)
stat64("libc.so.so", 0xbffff4d8)        =3D -1 ENOENT (No such file or dire=
ctory)
access("libc.so.la", F_OK)              =3D -1 ENOENT (No such file or dire=
ctory)
stat64("libc.so.la", 0xbffff4d8)        =3D -1 ENOENT (No such file or dire=
ctory)
open("/usr/lib/libc.so", O_RDONLY)      =3D 8
read(8, "/* GNU ld script\n   Use the shar"..., 1024) =3D 178
close(8)                                =3D 0
access("libc.so", F_OK)                 =3D -1 ENOENT (No such file or dire=
ctory)
stat64("libc.so", 0xbffff4e8)           =3D -1 ENOENT (No such file or dire=
ctory)
access("libc.so.so", F_OK)              =3D -1 ENOENT (No such file or dire=
ctory)
stat64("libc.so.so", 0xbffff4d8)        =3D -1 ENOENT (No such file or dire=
ctory)
access("libc.so.la", F_OK)              =3D -1 ENOENT (No such file or dire=
ctory)
stat64("libc.so.la", 0xbffff4d8)        =3D -1 ENOENT (No such file or dire=
ctory)
open("/usr/lib/libc.so", O_RDONLY)      =3D 8
read(8, "/* GNU ld script\n   Use the shar"..., 1024) =3D 178
close(8)                                =3D 0
getpid()                                =3D 18635
brk(0x823c000)                          =3D 0x823c000
write(2, "\n** (process:18635): WARNING **:"..., 74) =3D 74

--=-l6tmt4N3bZp+HIrGFhC1--