Czech

g++

Importing Lua programming language


06.04.25

In SUSE linux install following packages:
lua
lua-devel
or we can download latest Lua version from
http://www.lua.org/

Write simple source file test.cpp, which open and close Lua virtual machine:

extern "C" 
{
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
}



int main(int argc, char *argv[])
{
// Open Lua virtual machine

lua_State* luaVM = lua_open();
if (NULL == luaVM)
{
cout << "Error Initializing lua\n" << endl;
return;
}
cout << "Lua is inicialized" << endl;
// Close Lua virtual machine
lua_close(luaVM);
return 0;
}


Now we add the Lua library to the makefile
LOADLIBES = -lauxlib -llua -llualib -ldl
or compile
g++ -o test  test.cpp -L/usr/lib -lauxlib -llua -llualib -ldl





home / g++


Valid XHTML 1.0 Transitional