Lua is usually used as config file, like .ini , .xml
In this project, we use cpp load the variable, table, function in the lua script.
cd src/c++-call-lua
g++ -o test test.cpp -I ../../slua/include/ -L ../../slua/lib/ ../../slua/lib/linux/liblua.a
./test
str = this is lua
tbl:name = mao
Result is 30
We create a module function in cpp file, register it to the lua interpreter, and cpp file execute the lua script. At last, in the lua script ,we call the registered function.
cd src/lua-call-c++
g++ -o test test.cpp -I ../../slua/include/ -L ../../slua/lib/ ../../slua/lib/linux/liblua.a -ldl
./test
The average is 30
The sum is 150
Please enter to exit ...