lua是一個腳本語言,可以嵌入到c/c++中,它是世界上最小巧的腳本語言。
學(xué)習(xí)它可以大大的擴充對數(shù)據(jù)設(shè)置方面的許多要求。
lua,在西班人稱之月亮寶石,的確,把它掌握,把它嵌在vc之寶劍劍柄之上,
將讓你砍殺一切“攔路之怪獸”增加魔法之光彩!
首先,lua可以運行在windows平臺,但是你必須下載源碼對它編譯,下載地址在
如果采用vc6以上的話,編譯文件在\LUA\lua-5.1.1\etc中的bat中,
如何構(gòu)建lua,help有很清楚的解釋
* Building Lua on Windows and other systems
-----------------------------------------
If you're not using the
usual Unix tools, then the instructions for
building Lua depend on the
compiler you use. You'll need to create
projects (or whatever your
compiler uses) for building the library,
the interpreter, and the
compiler, as follows:
library: lapi.c lcode.c ldebug.c ldo.c ldump.c lfunc.c lgc.c
llex.c
lmem.c lobject.c lopcodes.c lparser.c lstate.c
lstring.c
ltable.c ltm.c lundump.c lvm.c
lzio.c
lauxlib.c lbaselib.c ldblib.c liolib.c lmathlib.c
loslib.c
ltablib.c lstrlib.c loadlib.c linit.c
interpreter: library, lua.c
compiler: library, luac.c print.c
If you use Visual Studio .NET, you can use etc/luavs.bat
in its "Command Prompt".
If all you want is to build the Lua interpreter, you may put all .c
files
in a single project, except for luac.c and print.c. Or just use
etc/all.c.
To use Lua as a library in your own programs, you'll need to know
how to
create and use libraries with your compiler.
As mentioned above, you may edit luaconf.h to select some features
before
building Lua.
在vc中做,很簡單,如果想靜態(tài)的,先生成一個空靜態(tài)工程文件,加入以上文件,就建出library。lib文件,如果想生成動態(tài)的,則建一個動態(tài)工程文件,加入以上文件,就建成library。dll和library。lib文件。
如果要建一個一個編譯器,則把上面的lib,和lua。c和print。c放在一個新win32控制臺工程文件編譯,形成了dos界面的exe,在dos下運行,生成的lua.exe如下
。
腳本解釋器,就是把lua。c和lib文件放在一個空win32工程文件編輯成luaw.exe
寫一個簡單的“hello world”文件,如下
print( “hello world”) 保存為hello。lua,
在dos下運行huae hello。lua
將會打印出字符串。
好了,第一篇介紹完。