OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Calling .so libraries under Linux

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
rildopragana
Newbie
Newbie


Joined: 08 Jun 2005
Posts: 3

PostPosted: Mon Jun 13, 2005 2:00 pm    Post subject: Calling .so libraries under Linux Reply with quote

I'm with m680 on Linux. What should I do to call a C shared library function? The following code don't work, it returns "error loading the DLL".
I have changed the library to "ncurses" (without the lib preffix), "libncurses" (without the suffix .so), and several other combinations without success. What am I doing wrong?

Also, the ChDir statement don't change the current directory (the msbox in the line after it returns the previous current dir). Are all those functions only supposed to work under MS-Windows?

Please, give me some hints!

Code:

Declare Sub beep Lib "/usr/lib/libncurses.so" Alias "beep" ( )

Sub ExampleDeclare
ChDir("/tmp")
msgbox curdir()
print fileExists("/usr/lib/libncurses.so")
beep()
FreeLibrary("/usr/lib/libncurses.so" )
End Sub
Back to top
View user's profile Send private message
Danad
OOo Advocate
OOo Advocate


Joined: 22 Feb 2004
Posts: 293
Location: Brasil

PostPosted: Mon Jun 13, 2005 4:28 pm    Post subject: Reply with quote

I think you can't use .so libraries (only win dll).

Some RTL file functions like chDir don't work fine. Instead, use SimpleFileAccess service:

An example:
http://www.oooforum.org/forum/viewtopic.phtml?p=17049

More here (look for chapter 11 section 11.3.1 - File I/O ):
http://api.openoffice.org/docs/DevelopersGuide/DevelopersGuide.htm

HTH
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Tue Jun 14, 2005 7:57 am    Post subject: Reply with quote

See :
Call an external program with macro http://www.oooforum.org/forum/viewtopic.phtml?t=6117
Using DLL in a macro http://www.oooforum.org/forum/viewtopic.phtml?t=2455&highlight=
declare DLL and runtime error http://www.oooforum.org/forum/viewtopic.phtml?t=17317
Declare DLL does not work in a different module http://www.oooforum.org/forum/viewtopic.phtml?t=17346&highlight=
shell command - How do I see the results of my shell command http://www.oooforum.org/forum/viewtopic.phtml?t=9503
using shell command in Openoffice version 1.1.4 http://www.oooforum.org/forum/viewtopic.phtml?t=19972&highlight=
Escape Characters : http://www.oooforum.org/forum/viewtopic.phtml?t=19831&highlight=
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
rildopragana
Newbie
Newbie


Joined: 08 Jun 2005
Posts: 3

PostPosted: Tue Jun 14, 2005 11:25 am    Post subject: Reply with quote

Thanks Serge, but I found the answer in the source code of the StarBasic interpreter. According the following lines from basic/source/runtime/dllmgr.cxx, Linux (and other unices as well) are second class environments for OOo Sad

Code:
SbiDllHandle SbiDllMgr::CreateDllHandle( const ByteString& rDllName )
{       
#if defined(MAC) || defined(UNX)
    SbiDllHandle hLib=0;
#else
    SbiDllHandle hLib;
#endif

#if defined(WIN)
    hLib = LoadLibrary( (const char*)rDllName );
    if( (ULONG)hLib < 32 )
        hLib = 0;
  ...     


It is a shame, because loading .so libraries is so easy or easier than Win* .DLLs. Only MS-Wincrap and OS/2 libraries are supported. Unfortunatelly, my application requires a fast bidirectional communication between OOo and my code. Sockets in Basic locks during reads and are too sloooow in OOo implementation, pipes and also fifos [named pipes] are not supported by the SimpleFile service, and so on. Only the clipboard was left to make my communication. Of course, there is the Shell() command and the environment to exchange messages, but this is a slower yet alternative. And the scriptngs framework don't (at least yet) support tcl (which I need) and is not easy to create another uno bridge. And I plan to stay very away from Java (arg!!!!!) code.
So, we can conclude OOo is a nice environment, well guarded under a crystal shield, pratically unable to talk to any other.

Anyway, thanks for your effort and fine links collection!
_________________
Rildo Pragana
http://pragana.net/
Recife, PE - Brazil
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Wed Jun 15, 2005 6:10 am    Post subject: Reply with quote

rildopragana wrote:
... the scriptngs framework don't (at least yet) support tcl (which I need) and is not easy to create another uno bridge. And I plan to stay very away from Java (arg!!!!!) code.
So, we can conclude OOo is a nice environment, well guarded under a crystal shield, pratically unable to talk to any other.


There is a .NET (and presumably Mono) bridge for UNO in the works.

There is a working Python bridge right now. I use it.

While I don't have anything against Java, and am hopeful to see GCJ supported soon so that Java works as natively compiled code rather than JVM code; I find Java very difficult to use with OOo's API because of all of the queryInterface.

For similar reasons, I suspect (but don't know) that C++ is similarly difficult to use. Constantly having to cast to the right interface before you can call a method.

Basic, Python and JavaScript are a breeze. JavaScript and Basic are only supported as a scripting language. Python can be used for scripting, components, or external programs running outside of the office -- even on a different computer-- even a different OS.

Even if Basic could load .so files, it would give you portability problems similar to what Windows users get when they use DLL's. If I write a component in Java or Python, or if I write a script in Basic, JavaScript, Python, or Java (BeanShell), then it works on OOo on any platform. Even if that platform is not yet invented. For example, suppose that somebody ports OOo over to SkyOS, or BeOS. Then my components and scripts just work. Use of non-portable features like .so's and DLL's won't work.

The .NET bridge would (presumably) have the same benefit. You could write in any language for .NET, not just C#, and then code could presumably work on any platform that OOo runs on.
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
hector
General User
General User


Joined: 11 Apr 2004
Posts: 6
Location: France

PostPosted: Thu Jun 03, 2010 12:21 am    Post subject: Reply with quote

I made an issue here for the possibility to load shared libraries in linux OS.
http://qa.openoffice.org/issues/show_bug.cgi?id=112064
Please vote it !
No discrimination !
Wink
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group