[Mono-bugs] [Bug 635203] New: DllImport-ing a function from libc.so yields a DllNotFoundException

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Aug 27 14:46:53 EDT 2010



           Summary: DllImport-ing a function from libc.so yields a
    Classification: Mono
           Product: Mono: Runtime
           Version: 2.6.x
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: interop
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: jccyc1965 at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:
Gecko/20100723 Fedora/3.6.7-1.fc13 Firefox/3.6.7

If I run the code below, I get a DllNotFoundException. But if, instead of
"libc.so", I use "libc.so.6", it works. In Fedora 13, which I'm using, libc.so
is a link script. Something in the runtime apparently should understand its
syntax but doesn't.

The code:
using System;
using System.Runtime.InteropServices;

namespace LinuxCaller
    class MainClass
        private static extern int getpid();

        public static void Main (string[] args)
            Console.WriteLine ("Hello World from process {0}!", getpid());

The contents of /usr/lib/libc.so in an up-to-date x86 Fedora 13:
/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a  AS_NEEDED (
/lib/ld-linux.so.2 ) )

Mono is 2.6.4, MonoDevelop is 2.2.2.

Reproducible: Always

Steps to Reproduce:
1. Create a console project in MonoDevelop
2. Paste the code above
3. Build; run.
Actual Results:  
Unhandled Exception: System.DllNotFoundException: /usr/lib/libc.so
  at (wrapper managed-to-native) LinuxCaller.MainClass:getpid ()
  at LinuxCaller.MainClass.Main (System.String[] args) [0x00000] in <filename

Expected Results:  
Hello World from process 6123!

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the mono-bugs mailing list