[Mono-list] Difficulty with DllImport in mono - config.AG_Config file is not in load-path.
S James S Stapleton
stapleton.41 at osu.edu
Tue Mar 22 09:18:09 EDT 2011
OK, I found my problem.
When I wrote some C code to open the .so, dlerror() is giving me an 'undefined symbol' error. Nothing to do with Mono at all.
Thanks,
-Jim Stapleton
----- Original Message -----
From: STEVEN STAPLETON
To: mono-list at lists.ximian.com
Sent: Saturday, March 19, 2011 1:27 PM
Subject: Re: [Mono-list] Difficulty with DllImport in mono - config.AG_Config file is not in load-path.
I don't mind sharing the wrapper code (I plan on BSD'ing it anyway). Should I put it on a web server for anyone to access, or should I attach it to a mail?
I am compiling it without the .dll extension - however VS2010 is adding it implicitly it seems - that's why I added the extra stuff to the .config file (see original mail). It works for the two functions that get called from ag_core up
to that point (AG_InitCore, AG_GetError).
A quick example of the imports:
//does not work
[DllImport("ag_gui", EntryPoint="AG_InitGraphics", ExactSpelling=true, CallingConvention=CallingConvention.Cdecl)]
static public extern Int32 InitGraphics(string driver);
//works
[DllImport("ag_core", EntryPoint="AG_InitCore", ExactSpelling=true, CallingConvention=CallingConvention.Cdecl)]
static private extern Int32 AG_InitCore(string progname, Uint32 flags);
//works
[DllImport("ag_core", EntryPoint="AG_Getopt", ExactSpelling=true, CallingConvention=CallingConvention.Cdecl)]
static private extern Int32 AG_Getopt(Int32 argc, string[] argv, string fmt, out string v, out Int32 index);
//works
[DllImport("ag_core", EntryPoint="AG_GetError", ExactSpelling=true, CallingConvention=CallingConvention.Cdecl)]
static public extern string GetError();
Thanks,
-Jim Stapleton
----- Original Message -----
From: Danny <dgortonii at gmail.com>
Date: Saturday, March 19, 2011 4:39 pm
Subject: Re: [Mono-list] Difficulty with DllImport in mono - config.AG_Config file is not in load-path.
To: jims <stapleton.41 at osu.edu>
Cc: mono-list at lists.ximian.com
> Without seeing your wrapper code, I'd guess that your DllImport
> statements include the file extension (.dll). To make the
> lookup work
> properly on Linux/Mono you either need to exclude the file
> extension
> (ie: just use 'ag_gui' - both .NET and Mono will resolve this
> correctly
> if the file is in a proper search path) so the native naming
> schemes can
> be used on the respective platforms, or use a DllMap in your
> config file
> to tell mono how to map ag_gui.dll (and others).
>
> On 03/19/2011 11:55 AM, jims wrote:
> > Background, I am working on a C# wrapper for Agar (
> http://libagar.org/ ) in
> > Visual Studio express 2010. I have knocked the .NET framework
> target down to
> > 2.0 to improve platform compatibility, for users of older software.
> >
> > When I try to run the first demo, I get this error:
> > [sjss at elrond ~/Desktop/Agar.NET_Demo]$ mono ./AgarDemo_Windows.exe
> > [DllNotFoundException:ag_gui.dll]The //config.AG_Config file
> is not in
> > load-path.
> >
> > verification it exists:
> > [sjss at elrond ~/Desktop/Agar.NET_Demo]$ ls -l /usr/local/lib |
> grep -e
> > 'libag_.*.so'
> > lrwxr-xr-x 1 root
> wheel 17 Mar 18 15:39
> libag_core.so ->
> > libag_core.so.1.4
> > -rw-r--r-- 1 root wheel
> 299513 Mar 18 14:54 libag_core.so.1.4
> > lrwxr-xr-x 1 root
> wheel 16 Mar 18 15:39
> libag_dev.so ->
> > libag_dev.so.1.4
> > -rw-r--r-- 1 root
> wheel 70586 Mar 18 14:54 libag_dev.so.1.4
> > lrwxr-xr-x 1 root
> wheel 16 Mar 18 15:39
> libag_gui.so ->
> > libag_gui.so.1.4
> > -rw-r--r-- 1 root wheel 1246374
> Mar 18 14:54 libag_gui.so.1.4
> > lrwxr-xr-x 1 root
> wheel 17 Mar 18 15:39
> libag_math.so ->
> > libag_math.so.1.4
> > -rw-r--r-- 1 root wheel
> 328560 Mar 18 14:54 libag_math.so.1.4
> > lrwxr-xr-x 1 root
> wheel 15 Mar 18 15:39
> libag_rg.so ->
> > libag_rg.so.1.4
> > -rw-r--r-- 1 root wheel
> 255964 Mar 18 14:54 libag_rg.so.1.4
> > lrwxr-xr-x 1 root
> wheel 15 Mar 18 15:39
> libag_vg.so ->
> > libag_vg.so.1.4
> > -rw-r--r-- 1 root wheel
> 205641 Mar 18 14:54 libag_vg.so.1.4
> >
> >
> > I have installed Agar, FreeType and SDL on my machine, all the
> libs are in
> > /usr/local/lib, are in my libpath, and the directory has been
> ldconfig'ed> for good measure after the first time I saw the error.
> >
> > Since Visual Studio 2010 wants to add the '.dll' to the first
> argument of
> > the DllImport call, I have added the following to the
> section of the config
> > config of all of my .NET dlls/exes:
> >
> >
> >
> >
> > ag_core.so is loading properly, the error message is produced by:
> >
> System.Console.WriteLine("["+e.GetType().Name+":"+e.Message+"]" +
> > Agar.GetError()+"\n");
> >
> > The Agar.GetError() part is what I find interesting - that
> requires that
> > ag_core be called. I *believe* the "//config.AG_Config file is
> not in
> > load-path." portion of the error is being set by an earlier
> portion of the
> > code in a manner that doesn't cause an exception or problem,
> as a warning.
> > Regardless, it shouldn't make "ag_gui" unlocatable.
> >
> >
> > Any ideas what I should look into next?
> > Thanks,
> > -Jim Stapleton
> >
> > --
> > View this message in context:
> http://mono.1490590.n4.nabble.com/Difficulty-with-DllImport-in-
> mono-config-AG-Config-file-is-not-in-load-path-tp3389891p3389891.html
> > Sent from the Mono - General mailing list archive at Nabble.com.
> > _______________________________________________
> > Mono-list maillist - Mono-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-list
> >
>
>
> --
> BEGIN-ANTISPAM-VOTING-LINKS
> ------------------------------------------------------
>
> Teach CanIt if this mail (ID 1171312426) is spam:
> Spam:
> about:blankNot spam: about:blank
> Forget vote:
> about:blank---
> ---------------------------------------------------
> END-ANTISPAM-VOTING-LINKS
>
------------------------------------------------------------------------------
Spam
Not spam
Forget previous vote
------------------------------------------------------------------------------
_______________________________________________
Mono-list maillist - Mono-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20110322/5c8b06bb/attachment-0001.html
More information about the Mono-list
mailing list