Re: [Mono-list] Can't get a simple shared object to be used - DllNotFoundException

2013-08-02 Thread thomasw234
Thanks for all of your replies. Unfortunately I've already tried most of what
was suggested, except modifying LD_LIBRARY_PATH. The only resource that my
shared object is using is stdio.h, do I need to add the path of that?

I've managed to take a screenshot from the machine which hopefully shows
more of what's going on. It's a bit messy unfortunately:

http://mono.1490590.n4.nabble.com/file/n4660340/Screenshot_from_2013-07-31_08_49_18.png
 

Bottom right terminal - shows the contents of test.c, and it being compiled
to libshared.so. Also shows that libshared.so and Test2.exe are in the same
directory.

Bottom left window - shows the DLLNotFoundException.

Top right window - the output from the c# program

Main window - the code executing in MonoDevelop.

Thanks,
Thomas



--
View this message in context: 
http://mono.1490590.n4.nabble.com/Can-t-get-a-simple-shared-object-to-be-used-DllNotFoundException-tp4660332p4660340.html
Sent from the Mono - General mailing list archive at Nabble.com.
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Can't get a simple shared object to be used - DllNotFoundException

2013-08-02 Thread thomasw234
Also, running with MONO_DEBUG_LEVEL=debug outputs a lot, but this seems like
the relevant part:



Somehow it's looking right at the file and deciding that it's not there,
which is what led me to believe that it might be a platform problem, but as
I said, compiling the shared object to 32bit instead of 64bit made no
difference :(



--
View this message in context: 
http://mono.1490590.n4.nabble.com/Can-t-get-a-simple-shared-object-to-be-used-DllNotFoundException-tp4660332p4660341.html
Sent from the Mono - General mailing list archive at Nabble.com.
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


[Mono-list] Can't get a simple shared object to be used - DllNotFoundException

2013-08-02 Thread thomasw234
Hi,

I'm trying to get my head around making use of Linux shared object files. I
have created a basic C-based shared object which prints (Shared Object
Called) when main() is called. Compiled it in gcc with -fPIC and got
libshared.so as an output.

Go into C#, add [DllImport(libshared.so)] public static extern int main();
Call main(), get a DllNotFoundException. libshared.so is in the same
directory as the c# program.

I thought it might be a platform problem (I'm using 64 bit fedora 18, and 64
bit mono 3.20), but I've tried building the shared object with both -m32 and
-m64 arguments, with no luck.

I can provide code if it helps, but the machine that I'm building is a
corporate machine that isn't allowed on the internet, so I'll have to copy
it out line-by-line.

Thanks,
Thomas



--
View this message in context: 
http://mono.1490590.n4.nabble.com/Can-t-get-a-simple-shared-object-to-be-used-DllNotFoundException-tp4660332.html
Sent from the Mono - General mailing list archive at Nabble.com.
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Can't get a simple shared object to be used - DllNotFoundException

2013-07-31 Thread Ian Norton
Here we go, I was on my nexus yesterday so couldnt easily grab these:

http://www.mono-project.com/Interop_with_Native_Libraries
http://www.mono-project.com/DllNotFoundException
http://www.mono-project.com/Config_DllMap

Ian


On 31 July 2013 03:33, Jonathan Pryor jonpr...@vt.edu wrote:

 On Jul 30, 2013, at 5:34 PM, Stifu st...@free.fr wrote:
  I've never done that myself, but if I remember correctly, you're not
 supposed to add the .so part. Just do [DllImport(libshared)].

 Close; you should prefer [DllImport(shared)], with one exception. On
 Windows, this will try to load SHARED.DLL, on Linux it will load
 libshared.so, and on OS X it will load libshared.dylib.

 The exception is that if the library name contains a '.', Windows
 LoadLibrary() will not automatically append a .DLL extension, so this would
 always fail:

 [DllImport(gtksharp-2.0)]

 In these cases, you should use the full Windows filename, and provide a
 .dll.config file so that the file can be found on other platforms:

 [DllImport(libgtksharp-2.0.dll)]

 - Jon

 ___
 Mono-list maillist  -  Mono-list@lists.ximian.com
 http://lists.ximian.com/mailman/listinfo/mono-list

___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Can't get a simple shared object to be used - DllNotFoundException

2013-07-30 Thread Stifu
I've never done that myself, but if I remember correctly, you're not supposed
to add the .so part. Just do [DllImport(libshared)]. That way, it's up
to the framework to figure out the right extension depending on the OS it
runs on.

In other words, that'd mean it can't find your file because it's looking for
libshared.so.so.


thomasw234 wrote
 Hi,
 
 I'm trying to get my head around making use of Linux shared object files.
 I have created a basic C-based shared object which prints (Shared Object
 Called) when main() is called. Compiled it in gcc with -fPIC and got
 libshared.so as an output.
 
 Go into C#, add [DllImport(libshared.so)] public static extern int
 main(); Call main(), get a DllNotFoundException. libshared.so is in the
 same directory as the c# program.
 
 I thought it might be a platform problem (I'm using 64 bit fedora 18, and
 64 bit mono 3.20), but I've tried building the shared object with both
 -m32 and -m64 arguments, with no luck.
 
 I can provide code if it helps, but the machine that I'm building is a
 corporate machine that isn't allowed on the internet, so I'll have to copy
 it out line-by-line.
 
 Thanks,
 Thomas





--
View this message in context: 
http://mono.1490590.n4.nabble.com/Can-t-get-a-simple-shared-object-to-be-used-DllNotFoundException-tp4660332p4660334.html
Sent from the Mono - General mailing list archive at Nabble.com.
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Can't get a simple shared object to be used - DllNotFoundException

2013-07-30 Thread Ian Norton
Dllimport tells the loader the library name.

A large combination of things work as library loading and shared objects
differ greatly on windows and unix.

On windows, the library could be installed in the side-by-side cache or in
the same folder as your assembly etc.

If you have a file called libfoo.so then best practice would be to do
DllImport(foo)

If that still doesn't work then you may actually be missing a library
required by foo and may need to set LD_LIBRARY_PATH or the equivalent on
your platform.

You might also need to mess with dllmap config files too
On 30 Jul 2013 22:35, Stifu st...@free.fr wrote:

 I've never done that myself, but if I remember correctly, you're not
 supposed
 to add the .so part. Just do [DllImport(libshared)]. That way, it's up
 to the framework to figure out the right extension depending on the OS it
 runs on.

 In other words, that'd mean it can't find your file because it's looking
 for
 libshared.so.so.


 thomasw234 wrote
  Hi,
 
  I'm trying to get my head around making use of Linux shared object files.
  I have created a basic C-based shared object which prints (Shared Object
  Called) when main() is called. Compiled it in gcc with -fPIC and got
  libshared.so as an output.
 
  Go into C#, add [DllImport(libshared.so)] public static extern int
  main(); Call main(), get a DllNotFoundException. libshared.so is in the
  same directory as the c# program.
 
  I thought it might be a platform problem (I'm using 64 bit fedora 18, and
  64 bit mono 3.20), but I've tried building the shared object with both
  -m32 and -m64 arguments, with no luck.
 
  I can provide code if it helps, but the machine that I'm building is a
  corporate machine that isn't allowed on the internet, so I'll have to
 copy
  it out line-by-line.
 
  Thanks,
  Thomas





 --
 View this message in context:
 http://mono.1490590.n4.nabble.com/Can-t-get-a-simple-shared-object-to-be-used-DllNotFoundException-tp4660332p4660334.html
 Sent from the Mono - General mailing list archive at Nabble.com.
 ___
 Mono-list maillist  -  Mono-list@lists.ximian.com
 http://lists.ximian.com/mailman/listinfo/mono-list

___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Can't get a simple shared object to be used - DllNotFoundException

2013-07-30 Thread Jonathan Pryor
On Jul 30, 2013, at 5:34 PM, Stifu st...@free.fr wrote:
 I've never done that myself, but if I remember correctly, you're not supposed 
 to add the .so part. Just do [DllImport(libshared)].

Close; you should prefer [DllImport(shared)], with one exception. On Windows, 
this will try to load SHARED.DLL, on Linux it will load libshared.so, and on OS 
X it will load libshared.dylib.

The exception is that if the library name contains a '.', Windows LoadLibrary() 
will not automatically append a .DLL extension, so this would always fail:

[DllImport(gtksharp-2.0)]

In these cases, you should use the full Windows filename, and provide a 
.dll.config file so that the file can be found on other platforms:

[DllImport(libgtksharp-2.0.dll)]

- Jon

___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list