Calling C shared library function from LibreOffice Basic -
i'm trying phone call c shared library function libreoffice basic, "basic runtime error. not implemented" when hits declare line. it's fun thing beingness unable bugging me.
the declare statement looks this:
declare function score_word lib "libscrabblescore.so" (byref word string, byref bonus string) integer
the c function delaration looks this:
int score_word(char* word, char* word_bonuses)
(maybe byref word string not right translation of char* word? can't find documentation on how utilize char* parameters functions libreoffice basic.)
i validated shared library calling using python's ctypes module:
>>> ctypes import cdll >>> lib = cdll("/usr/lib/libscrabblescore.so") >>> lib.score_word("qi", "dw dlq") 42 >>> (so have "answer ultimate question of life, universe, , everything," not how in libreoffice basic!)
i tried using absolute path in declare statement well, , made no difference.
i found windows thread on topic of calling dll's asker said needed set dll in specific location (the libreoffice bin directory) libreoffice access it. there no libreoffice bin directory per-se on linux, , unfortunately there 351 candidate directories able identify on machine (my path, , folders "libreoffice" in name or under folder "libreoffice" in name).
i tried shotgun approach , set symbolic link shared library in 351 directories, calc hangs on startup. removed those, started calc, , set them in place , tried function. if location thing, you'd think work libreoffice basic supposed load library @ point of declare. still no luck.
there looked promising on oooforums site times out when seek view thread. (edit: managed view thread eve , windows security problem. turned off macro security in libreoffice , still have problem.)
so, has ever called c shared library function libreoffice basic programme knows i'm doing wrong? thanks!
jonathon reinhart correct; "declare" command calling shared libraries implemented on windows not on linux. able verify because of reference openoffice bug study on matter on blog post.
my first effort @ solution rewrite function in libreoffice basic. worked, take 3 seconds homecoming results.
i considered giving , leaving that, unpleasant have 3 sec wait. looked how implement c++ function through uno, overly complex trivial task.
finally did write kludge still gives "instant" results (around 0.025 seconds each function call).
i rewrote dll c++ console app takes command line arguments , writes result temp file. replaced libreoffice basic code function calls c++ console app in blocking mode using shell , retrieves results file. it's ugly, it's not multi-user thing , works.
in case stumbles across issue themselves, here's libreoffice basic code used this--it's simple.
option explicit function scorewords(wordlist string, bonuslist string) integer dim cparams string dim fileno integer dim results_file string dim score integer if wordlist = "" scorewords = 0 exit function end if cparams = """" + wordlist + """" + " " + """" + bonuslist + """" results_file = "/tmp/scrabblescore.dat" shell("/usr/bin/getscrabblescore", 6, cparams, true) fileno = freefile open results_file input fileno input #fileno, score close #fileno kill results_file scorewords = score end function c shared-libraries libreoffice-calc libreoffice-basic
No comments:
Post a Comment