[MonoDevelop] Newbie question: Making a reference to a linux shared library

alanb alan.battersby at ntlworld.com
Mon Oct 6 08:50:42 EDT 2008


I am still not able to load the shared library. I have copied the shared
library into the /bin/Debug directory of my main C# app and set the
LD_LIBRARY_PATH to be an absolute address. See below I have tried all
combinations of dll name in the DllImport statement including the full name
and not just the link.
<code>  
mono abtools.exe
Exception in Gtk# callback delegate
  Note: Applications can use GLib.ExceptionManager.UnhandledException to
handle the exception.
System.DllNotFoundException: libtest.so.1.0
  at (wrapper managed-to-native) emcConnect.EmcConnection:tryNml ()
  at MainWindow.OnAddActionActivated (System.Object sender, System.EventArgs
e) [0x00000] 
  at GLib.Signal.voidObjectCallback (IntPtr handle, IntPtr data) [0x00000] 
   at GLib.ExceptionManager.RaiseUnhandledException(System.Exception e,
Boolean is_terminal)
   at GLib.Signal.voidObjectCallback(IntPtr handle, IntPtr data)
   at GLib.Signal.voidObjectCallback(IntPtr , IntPtr )
   at Gtk.Application.gtk_main()
   at Gtk.Application.gtk_main()
   at Gtk.Application.Run()
   at abtools.MainClass.Main(System.String[] args)
alan at alan-laptop:/media/Data/CNC/abtools v1.5/abtools/bin/Debug$ echo
$LD_LIBRARY_PATHLD_LIBRARY_PATH$:/media/Data/CNC/abtools
v1.5/abtools/bin/Debug/
alan at alan-laptop:/media/Data/CNC/abtools v1.5/abtools/bin/Debug$ ls
abtools.exe          abwidgetlibrary.dll.mdb  GenTemplates.dll     
libtest.so.1.0
abtools.exe.config   basic.dll                GenTemplates.dll.mdb 
OpenTK.dll
abtools.exe.config~  basic.dll.mdb            GLWidget.dll         
OpenTK.dll.config
abtools.exe.mdb      emcConnect.dll           libtest.so
abwidgetlibrary.dll  emcConnect.dll.mdb       libtest.so.1
</code>
but I am still getting a not found exception. I am obviously missing
something simple but cannot see what is wrong. Any more suggestions would be
more than welcome.

Alan

Petit Eric wrote:
> 
> 2008/10/6 alanb <alan.battersby at ntlworld.com>:
>>
>> I tried P/Invoke, I created a shared library, wrapped it in C# class and
>> it
>> all compiles ok. But when I try to execute one of the external functions
>> I
>> get an exception -  System.DllNotFoundException: libtest.so . As this is
>> an
>> experiment I do not want to place my library in /usr , /lib etc so I
>> tried
>> setting LD_LIBRARY_PATH in a shell but that doesnt seem to work for me. I
>> am
>> assuming that I need to set LD_LIBRARY_PATH in the shell created by
>> monodevelops run command, so can someone tell me how to do this?
> normaly yu can replace your dll call : libtest.so by libtest i folow
> this way fro lib ported to Win 32 ex : libtest.so and libtest.dll
> after , compile your prog with MD
> open a shell (konsole for ex) and browse to the bin/Debug or Release
> dir (depand how yu compile)
> then : export LD_LIBRARY_PATH=LD_LIBRARY_PATH$:what yu need && mono
> ./your.exe
> also i think, yu can call your test lib with an absolute path or
> relative to your compil directory
>>
>> Thanks
>> Alan
>>
>>
>> Petit Eric wrote:
>>>
>>> P/Invoke
>>>
>>>
>>> 2008/10/6 alanb <alan.battersby at ntlworld.com>:
>>>>
>>>> I tried adding a shared library as a reference to my C# project but it
>>>> wasn't
>>>> recognized. So is there a way to do this? If it is  not possible
>>>> directly
>>>> how do you wrap a .so file as a .dll that would be recognized?
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Newbie-question%3A-Making-a-reference-to-a-linux-shared-library-tp19835738p19835738.html
>>>> Sent from the Mono - MonoDevelop IDE mailing list archive at
>>>> Nabble.com.
>>>>
>>>> _______________________________________________
>>>> Monodevelop-list mailing list
>>>> Monodevelop-list at lists.ximian.com
>>>> http://lists.ximian.com/mailman/listinfo/monodevelop-list
>>>>
>>>
>>>
>>>
>>> --
>>>
>>> Cordially.
>>>
>>> Small Eric Quotations of the days:
>>> ---------------------------------------------------------------------------
>>> If one day one reproaches you that your work is not a work of
>>> professional, say you that:
>>> Amateurs built the arch of Noah, and professionals the Titanic.
>>> ---------------------------------------------------------------------------
>>>
>>> Few people are done for independence, it is the privilege of the
>>> powerful
>>> ones.
>>> ---------------------------------------------------------------------------
>>>
>>> No key was wounded during the drafting of this message.
>>> _______________________________________________
>>> Monodevelop-list mailing list
>>> Monodevelop-list at lists.ximian.com
>>> http://lists.ximian.com/mailman/listinfo/monodevelop-list
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Newbie-question%3A-Making-a-reference-to-a-linux-shared-library-tp19835738p19836211.html
>> Sent from the Mono - MonoDevelop IDE mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> Monodevelop-list mailing list
>> Monodevelop-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/monodevelop-list
>>
> 
> 
> 
> -- 
> 
> Cordially.
> 
> Small Eric Quotations of the days:
> ---------------------------------------------------------------------------
> If one day one reproaches you that your work is not a work of
> professional, say you that:
> Amateurs built the arch of Noah, and professionals the Titanic.
> ---------------------------------------------------------------------------
> 
> Few people are done for independence, it is the privilege of the powerful
> ones.
> ---------------------------------------------------------------------------
> 
> No key was wounded during the drafting of this message.
> _______________________________________________
> Monodevelop-list mailing list
> Monodevelop-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monodevelop-list
> 
> 

-- 
View this message in context: http://www.nabble.com/Newbie-question%3A-Making-a-reference-to-a-linux-shared-library-tp19835738p19837320.html
Sent from the Mono - MonoDevelop IDE mailing list archive at Nabble.com.



More information about the Monodevelop-list mailing list