loadlib failure

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

loadlib failure

abm0000abm-2
I'm using the libkit example in 2b10. Compile and hotsyncing the
library went fine. However, entering:

loadlib("TestLib2","TestLib2")
print(test.square(5))

fails with an "ERROR 1290" and then a nil test.

I've tried putting test instead of TestLib2 and various combinations
of the two, but no luck.

I'm using a Palm Centro.

I hope that there is a simple solution and not a bigger problem like
loadlib not working with the Centro.

I've tried other libkit examples and can't get them to work either.



Reply | Threaded
Open this post in threaded view
|

Re: loadlib failure

abm0000abm-2
in case anyone asks, I did try

loadlib("TestLib2","test")

loadlib("test","test")

loadlib("test","TestLib2")

as well as

loadlib("TestLib2","TestLib2")

All failed.

Reply | Threaded
Open this post in threaded view
|

Re: loadlib failure

migueletto-2
--- In [hidden email], kevinjardine <no_reply@...> wrote:
>
> in case anyone asks, I did try
> loadlib("TestLib2","test")
> loadlib("test","test")
> loadlib("test","TestLib2")
> as well as
> loadlib("TestLib2","TestLib2")
> All failed.

Since Plua 2.0b4, loadlib is the standard loadlib function present in
Lua 5.0. For an usage example, look at the LuaCalc.lua application
inside plua-2.0.examples.zip:

local l3dinit = loadlib("3dlib2","init")
if not l3dinit then
  gui.alert("This app requires 3dlib2.prc")
  os.exit()
end
l3dinit()

You must test if the function returned by loadlib is not null and then
call it to initialize the library. Also look at the PluaLibInit
function inside 3dlib.c in libkit. This is the C function that is
called when you call l3dinit in the example. The second argument is
supposed to be a C function name ("init" in this example), but PalmOS
does not support this. So inside PluaLibInit you can choose what
funtion to return based on the name argument.

Regards,
Marcio.



Reply | Threaded
Open this post in threaded view
|

Re: loadlib failure

abm0000abm-2
Thanks for the fast response, Marcio.

Just for the record, what worked for me is:

-- testing.lua
function init()
    local testinit = loadlib("TestLib2","init")
    assert(testinit,"nope")
    testinit()
    print(test.square(4))
    os.sleep(5)
end
init()

I don't understand why loadlib appears to refer to the function it is
sitting inside instead of a function in the library.

It would be great to add some libkit documentation to the otherwise
excellent Plua manual supplied with the interpreter. Plua is a
fantastic language - the best I've ever seen for the Palm, and libkit
opens the way to an incredible range of functions.

Thanks for giving us a great piece of software, Marcio!

--- In [hidden email], "migueletto" <migueletto@...> wrote:

> Since Plua 2.0b4, loadlib is the standard loadlib function present in
> Lua 5.0. For an usage example, look at the LuaCalc.lua application
> inside plua-2.0.examples.zip: