lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Yes, dynamic module support does need to be compiled into the kernel if
you want to dynamically load modules. It look as though you are running
this on a blackfin. I am not familiar with this processor, I have
compiled and run lua 5.1.4 under a uClinux system on the Coldfire.

Some things to be aware of;
IF the blackfin is a noMMU system, that is it doesn't have a memory
management unit, then dynmaic loading might be a bit tricky. In my case
on coldfire, which is noMMU, I compile lua statically. This is much
easier and less resource hungry than using dynamic module support. Of
course it depends on your use case, if you want end users to be able to
choose and load any old module then you might have to battle with
dynamic loading support. Of course end users can still use pure lua
modules with require, it only restricts use of .so/.dll based packages.
To include these you need to rebuild the lua libs including them.

To include c modules, like the sockets library, these are built at the
same time and statically linked. The question is then, how does lua load
them? Have a good look at the LOOP project, specifically the
pre-compiler and pre-loader features.
http://loop.luaforge.net/
http://loop.luaforge.net/release/preload.html

It took me a while to find this on the net, it is incredibly helpful in
automating the task of loading static libraries.

Basically what it does is examine your source files and produces code
that describes the functions lua should call to pre-load a library. You
could of course do this yourself, much easier when it is done for you.
What it produces is also a very good example of what you should/could
do. Then in 'linit.c' add your header and in 'luaL_openlibs()' add at
the end a call to the preloader function created (in my case
'luapreload_luasocketclibs(L);'). This adds the library to the
package.preload table in lua. When you require "socket" it loads the
library in the package.loaded table from here. Of course the built
'libsockets.o' (or whatever) needs to be in the include path of the lua
build.

It can also pre-compile lua scripts and make them available for pre-load
as well. I don't do this, I just include the scripts as source in the
search path of the file system. I just pre-load the c part of the
sockets library. I could get the precompilation working on a ubuntu host
system as a test, but when cross built for coldfire it wouldn't load. I
didn't really look into why, the c module preload worked fine so I just
left it at that.

You probably also should have a look (and buy, and read twice) the
excellent Programming in Lua book;
http://www.lua.org/pil/
The section on packages and how they are loaded is illuminating.

Hope this helps.

Regards,
dean<at>sellers.id.au

> -----Original Message-----
> From: lua-l-bounces@lists.lua.org 
> [mailto:lua-l-bounces@lists.lua.org] On Behalf Of Gilles Ganault
> Sent: Friday, 21 January 2011 9:22 AM
> To: lua-l@lists.lua.org
> Subject: Re: "dynamic libraries not enabled"?
> 
> 
> On Thu, 20 Jan 2011 18:42:37 -0200, Luiz Henrique de Figueiredo
> <lhf@tecgraf.puc-rio.br> wrote:
> >Does "-DLUA_USE_POSIX -DLUA_USE_DLOPEN" appear when make echoes
> >the compilation lines?
> 
> Yes it does. Here's the output when I run "make -f lua.mk", which cd's
> into lua-5.1.4/src and run its local Makefile:
> 
> www.pastebin.com/GEQrT069
> 
> I'm no Makefile expert, so it could be something obvious, though.
> 
> Another thing I thought of: Could it be that uClinux has to be
> compiled in a specific way to satisfy Lua requirements?
> 
> Thank you.
> 
> 
> 
> --
> This message was scanned by ESVA and is believed to be clean.
> Click here to report this message as spam. 
> http://mailscanner.rinstrum.com.au/cgi-bin/learn-msg.cgi?id=4E
5E2286DD.5271B