lua-users home
lua-l archive

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

Is it possible to precompile Lua functions to produce a library?  I have a 
MS Visual Studio project and make available Lua functions through the C code 
interface.  Users choose a script to run which calls back to my C routines. 
This works as expected.

I found that I was duplicating Lua functions in the different scripts.  I 
could have a .lua file that was loaded when the first script was read but 
I'd prefer to keep the library lua code out of the user's file system - not 
for secrecy reasons but just so that I don't have to depend on the presence 
of the file.

It seems that I should be able to precompile my Lua library as one of the 
prerequisites when I build the project.  Is there a description somewhere of 
the steps necessary to run the Lua interpreter and extract the string that 
represents the p-code that the actual represents the lua code?

Alternatively I could just define a long string in the C++ code that 
represents my Lua library routines and then at the first call, do a 
loadstring(...) on this text.

Is there a recommended way of incorporating my Lua library code in my 

Edward E.L. Mitchell
Phone: (239)415-7039
6707 Daniel Court
Fort Myers, FL 33908