LibreOffice Linux, xls vba code to call a so library

I am testing the Linux version of LibreOffice

Version: 6.0.7.3
Build ID: 1:6.0.7-0ubuntu0.18.04.10
CPU threads: 8; OS: Linux 5.0; UI render: default; VCL: x11; 
Locale: en-US (en_US.UTF-8); Calc: group

for tests I created a simple xls page with one macro (Sub mysub) to call a shared library test.so (64 bit, compiled with CLang and tested with Python), I have tested several modifications (meaning changing the “Private Declare Function mytest…”) of the code working with the Windows version

Private Declare Function mytest Lib "test.so" (ByVal p As Long) As Long

Sub mysub
Dim i As Long
i = mytest(5)
end Sub

however (in all my tests) when debugging (step by step) some variant of the code

Private Declare Function mytest Lib "test.so" (ByVal p As Long) As Long 

Libreoffice reports

BASIC runtime error. '73' Not implemented.

my questions :

1) does the LibreOffice Linux Basic allow to access my test.so library ?
2) if yes, which is the correct way to code this macro so that LibreOffice interpreter calls dlopen() or a equivalent system method ?

I understand that this request may appear basic but still I was unable to find a working example for Linux version of LibreOffice…

thanks for help.

Calling arbitrary shared objects’ functions from Basic is, well, not implemented…

You could however call a Python script from Basic, or omit Basic altogether and use Python right on, and Python in turn could handle the shared object call. See Basic to Python and ctypes — A foreign function library for Python — Python 3.9.6 documentation

thanks for help,
before to start testing with LibreOffice BASIC (creating a xls page with some code) I have tested the library from Python and it works fine,
unfortunatelly Python requires additional settings and I did hope that a simple solution (as that for LibreOffice windows) was available,
from your comments it appears that the BASIC intepreter in Linux version doesn’t allow to call shared libraries and I must look for alternatives…

Is there any technical or show-stopping reason (like maybe lack of SafeArrays in Linux, or potential litigation from Microsoft, etc) that .so support could not be added? Was the design decision to not support .so at this level made based on the presence of the Python connection?

I could (probably) do this work.

Python doesn’t do it for me.

I suggest to join the dev mailing list and get your hands dirty on the code :slight_smile:
See Developers | LibreOffice - Free Office Suite - Based on OpenOffice - Compatible with Microsoft

1 Like

Thanks, I will do this.