Generally, Lua. Lib is not used. How does it come from? It is actually very simple.
We all know that Lua is cross-platform and open-source. So we can see a lot of internal code, so as to provide convenience for Lib.
Let's explain the answer. Lua. lib can be automatically generated.
Below are detailed steps:
1. The VC project, Win32 static library, is named Lua.
2. Load all *. C and *. h In the SRC file under the Lua root path.
3. debug and release compile with you.
4. You can use Lua. Lib anywhere, of course, in windows.
/* VC example
* $ Chenxiong
$2009.11.12
*/
Extern "C "{
# Include "Lua. H"
# Include "lualib. H"
# Include "lauxlib. H"
}
# Pragma comment (Lib, "Lua. lib ")
# Include <stdio. h>
# Include <string>
# Include <conio. h>
Using namespace STD;
// "Luatest. Lua"
Int main (void)
{
Lua_state * l = lua_open ();/* initialize opens Lua to obtain the Lua state base */
Lual_openlibs (l); // load all the Lua standard Libraries
Lual_dofile (L, "luatest. Lua"); // execute luatest. Lua and add the assort function to the luatest. Lua stack.
Lua_getglobal (L, "assort"); // use the function name to extract the function address and press it into the stack.
Lua_pushstring (L, "Heihei"); // press the first parameter to the stack.
Lua_pcall (L, 0); // call the assort Function
Int I = (INT) lua_tonumber (L,-1 );
Lua_pop (L, 1 );
Printf ("is % d/N", I );
Lua_close (L );
Return 0;
}
-- [[Luatest. Lua... test function
2009.11.12]
I =-1
Bill = "Hello World"
Function assort (Bill)
D = string. Len (Bill)
If D> = 5 then
I = 1
Else
I = 0
End
Return I
End
Print (assort (Bill ))